[pypy-svn] r50047 - pypy/branch/ghop-ropes-classes/pypy/rlib

vinogradov at codespeak.net vinogradov at codespeak.net
Sun Dec 23 19:57:00 CET 2007


Author: vinogradov
Date: Sun Dec 23 19:57:00 2007
New Revision: 50047

Modified:
   pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
Log:
RopeString constructor now accept *Rope as argument

Modified: pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
==============================================================================
--- pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py	(original)
+++ pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py	Sun Dec 23 19:57:00 2007
@@ -2,7 +2,10 @@
 
 class RopeString(object):
     def __init__(self, s):
-        self._node = rope.LiteralStringNode(s)
+        if isinstance(s, str):
+            self._node = rope.LiteralStringNode(s)
+	if isinstance(s, rope.LiteralStringNode):
+            self._node = s
     
     def __len__(self):
         return self._node.length()
@@ -14,14 +17,10 @@
         return rope.eq(self._node, rope.LiteralStringNode(other))
     
     def __add__(self, other):
-        result = RopeString('')
-        result._node = self._node + other._node
-	return result
+        return RopeString(self._node + other._node)
     
     def __mul__(self, n):
-        result = RopeString('')
-        result._node = rope.multiply(self._node, n)
-        return result
+        return RopeString(rope.multiply(self._node, n))
     
     def __rmul__(self, n):
         return self * n



More information about the Pypy-commit mailing list