[pypy-svn] r50376 - pypy/branch/ghop-ropes-classes/pypy/rlib
vinogradov at codespeak.net
vinogradov at codespeak.net
Sun Jan 6 15:23:53 CET 2008
Author: vinogradov
Date: Sun Jan 6 15:23:52 2008
New Revision: 50376
Modified:
pypy/branch/ghop-ropes-classes/pypy/rlib/ropewrapper.py
Log:
Rewrite RopeString decode method. Use optimized rope.str_decode_* functions
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 Jan 6 15:23:52 2008
@@ -79,8 +79,18 @@
return RopeString(result)
def decode(self, codepage, errors='strict'):
- s = self._node.flatten_string()
- result = s.decode(codepage, errors)
+ result = None
+
+ if codepage == 'utf-8':
+ result = rope.str_decode_utf8(self._node)
+ if codepage == 'latin1':
+ result = rope.str_decode_latin1(self._node)
+ if codepage == 'ascii':
+ result = rope.str_decode_ascii(self._node)
+
+ if result == None:
+ s = self._node.flatten_string()
+ result = s.decode(codepage, errors)
return RopeUnicode(result)
def getchar(self,index):
More information about the Pypy-commit
mailing list