[pypy-svn] r49641 - pypy/dist/pypy/objspace/std

arigo at codespeak.net arigo at codespeak.net
Tue Dec 11 19:48:28 CET 2007


Author: arigo
Date: Tue Dec 11 19:48:26 2007
New Revision: 49641

Modified:
   pypy/dist/pypy/objspace/std/stringobject.py
   pypy/dist/pypy/objspace/std/stringtype.py
   pypy/dist/pypy/objspace/std/strjoinobject.py
Log:
Kill an obvious inefficiency.


Modified: pypy/dist/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stringobject.py	(original)
+++ pypy/dist/pypy/objspace/std/stringobject.py	Tue Dec 11 19:48:26 2007
@@ -12,7 +12,7 @@
 from pypy.objspace.std.tupleobject import W_TupleObject
 
 from pypy.objspace.std.stringtype import sliced, joined, wrapstr, wrapchar, \
-     stringendswith, stringstartswith
+     stringendswith, stringstartswith, joined2
 
 from pypy.objspace.std.formatting import mod_format
 
@@ -827,7 +827,7 @@
 def add__String_String(space, w_left, w_right):
     right = w_right._value
     left = w_left._value
-    return joined(space, [left, right])
+    return joined2(space, left, right)
 
 def len__String(space, w_str):
     return space.wrap(len(w_str._value))

Modified: pypy/dist/pypy/objspace/std/stringtype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stringtype.py	(original)
+++ pypy/dist/pypy/objspace/std/stringtype.py	Tue Dec 11 19:48:26 2007
@@ -58,6 +58,14 @@
     else:
         return wrapstr(space, "".join(strlist))
 
+def joined2(space, str1, str2):
+    assert not space.config.objspace.std.withrope
+    if space.config.objspace.std.withstrjoin:
+        from pypy.objspace.std.strjoinobject import W_StringJoinObject
+        return W_StringJoinObject([str1, str2])
+    else:
+        return wrapstr(space, str1 + str2)
+
 str_join    = SMM('join', 2,
                   doc='S.join(sequence) -> string\n\nReturn a string which is'
                       ' the concatenation of the strings in the\nsequence. '

Modified: pypy/dist/pypy/objspace/std/strjoinobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/strjoinobject.py	(original)
+++ pypy/dist/pypy/objspace/std/strjoinobject.py	Tue Dec 11 19:48:26 2007
@@ -2,7 +2,7 @@
 from pypy.objspace.std.stringobject import W_StringObject
 from pypy.objspace.std.unicodeobject import delegate_String2Unicode
 
-from pypy.objspace.std.stringtype import joined, wrapstr
+from pypy.objspace.std.stringtype import wrapstr
 
 class W_StringJoinObject(W_Object):
     from pypy.objspace.std.stringtype import str_typedef as typedef



More information about the Pypy-commit mailing list