diff options
| author | Steven Knight <knight@baldmt.com> | 2002-04-05 09:39:27 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2002-04-05 09:39:27 (GMT) |
| commit | 703eac076d304885578e80ea100453e768abb52b (patch) | |
| tree | 3122b200bda891612d3698596ee97b3403a65a6c | |
| parent | 863885a0df1f83b7e5b29f0370a865b4da330e24 (diff) | |
| download | SCons-703eac076d304885578e80ea100453e768abb52b.zip SCons-703eac076d304885578e80ea100453e768abb52b.tar.gz SCons-703eac076d304885578e80ea100453e768abb52b.tar.bz2 | |
Various performance enhancements. (Anthony Roach)
| -rw-r--r-- | src/CHANGES.txt | 6 | ||||
| -rw-r--r-- | src/engine/SCons/Builder.py | 8 | ||||
| -rw-r--r-- | src/engine/SCons/Node/__init__.py | 6 | ||||
| -rw-r--r-- | src/engine/SCons/Util.py | 23 | ||||
| -rw-r--r-- | src/engine/SCons/UtilTests.py | 5 |
5 files changed, 38 insertions, 10 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index fee7642..da541f3 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -20,6 +20,12 @@ RELEASE 0.07 - - Significant internal restructuring of Scanners and Taskmaster. + - Added new --debug=dtree option. + + - Fixes for --profile option. + + - Performance improvement in construction variable substitution. + RELEASE 0.06 - Thu, 28 Mar 2002 01:24:29 -0600 diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index e7af01c..2ccba00 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -64,7 +64,7 @@ def _init_nodes(builder, env, tlist, slist): the proper Builder information. """ for s in slist: - src_key = slist[0].scanner_key() # the file suffix + src_key = s.scanner_key() # the file suffix scanner = env.get_scanner(src_key) if scanner: s.source_scanner = scanner @@ -115,10 +115,8 @@ class BuilderBase: """ def adjustixes(files, pre, suf): ret = [] - if SCons.Util.is_String(files): - files = string.split(files) - if not SCons.Util.is_List(files): - files = [files] + files = SCons.Util.argmunge(files) + for f in files: if SCons.Util.is_String(f): if pre and f[:len(pre)] != pre: diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 67ad743..9c39d25 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -347,11 +347,7 @@ def arg2nodes(arg, node_factory=None): in the list are not split at spaces. In all cases, the function returns a list of Node instances.""" - narg = arg - if SCons.Util.is_String(arg): - narg = string.split(arg) - elif not SCons.Util.is_List(arg): - narg = [arg] + narg = SCons.Util.argmunge(arg) nodes = [] for v in narg: diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index ef998a9..e31b1b0 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -196,6 +196,12 @@ def scons_subst(strSubst, globals, locals, remove=None): surrounded by curly braces to separate the name from trailing characters. """ + + # Make the common case (i.e. nothing to do) fast: + if string.find(strSubst, "$") == -1 \ + and (remove is None or remove.search(strSubst) is None): + return strSubst + cmd_list = scons_subst_list(strSubst, globals, locals, remove) return string.join(map(string.join, cmd_list), '\n') @@ -238,6 +244,23 @@ def is_Dict(e): def is_List(e): return type(e) is types.ListType or isinstance(e, UserList.UserList) +def argmunge(arg): + """This function converts a string or list into a list of strings or Nodes. + It follows the rules outlined in the SCons design document by accepting + any of the following inputs: + - A single string containing names separated by spaces. These will be + split apart at the spaces. + - A single None instance + - A list containing either strings or Node instances. Any strings + in the list are not split at spaces. + In all cases, the function returns a list of Nodes and strings.""" + if is_List(arg): + return arg + elif is_String(arg): + return string.split(arg) + else: + return [arg] + if hasattr(types, 'UnicodeType'): def is_String(e): return type(e) is types.StringType \ diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index d230a08..60d7d4d 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -208,6 +208,11 @@ class UtilTestCase(unittest.TestCase): if hasattr(types, 'UnicodeType'): exec "assert not is_List(u'')" + def test_argmunge(self): + assert argmunge("foo bar") == ["foo", "bar"] + assert argmunge(["foo", "bar"]) == ["foo", "bar"] + assert argmunge("foo") == ["foo"] + def test_is_String(self): assert is_String("") if hasattr(types, 'UnicodeType'): |
