Make SCons.Util.to_String() more efficient.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 22 Feb 2003 13:17:05 +0000 (13:17 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 22 Feb 2003 13:17:05 +0000 (13:17 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@595 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Util.py

index dce8e349a4a5cd9b23d1c7643d4e2d629fe6af12..9fa0501d5404715e50d81c5d930869d9012bcd08 100644 (file)
@@ -23,6 +23,8 @@ RELEASE 0.12 - XXX
     from source code systems.  Add factory methods that create Builders
     to support BitKeeper, CVS, RCS, SCCS and Subversion.
 
+  - Make the internal to_String() function more efficient.
+
 
 
 RELEASE 0.11 - Tue, 11 Feb 2003 05:24:33 -0600
index 0d64e038f924fe4c2705768b12a77574395acd9c..fcadf48d3d19f7d899ba388719ed07b0ad47658e 100644 (file)
@@ -506,15 +506,18 @@ def is_Dict(e):
 def is_List(e):
     return type(e) is types.ListType or isinstance(e, UserList.UserList)
 
-def to_String(s):
-    """Better than str() because it will preserve a unicode
-    object without converting it to ASCII."""
-    if hasattr(types, 'UnicodeType') and \
-       (type(s) is types.UnicodeType or \
-        (isinstance(s, UserString) and type(s.data) is types.UnicodeType)):
-        return unicode(s)
-    else:
-        return str(s)
+if hasattr(types, 'UnicodeType'):
+    def to_String(s):
+        if isinstance(s, UserString):
+            t = type(s.data)
+        else:
+            t = type(s)
+        if t is types.UnicodeType:
+            return unicode(s)
+        else:
+            return str(s)
+else:
+    to_String = str
 
 def argmunge(arg):
     return Split(arg)