1. Pypy
  2. Untitled project
  3. pypy


Armin Rigo  committed 136884a

Kill an obvious inefficiency.

  • Participants
  • Parent commits f8de8c5
  • Branches default

Comments (0)

Files changed (3)

File pypy/objspace/std/stringobject.py

View file
  • Ignore whitespace
 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
 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))

File pypy/objspace/std/stringtype.py

View file
  • Ignore whitespace
         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. '

File pypy/objspace/std/strjoinobject.py

View file
  • Ignore whitespace
 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