Author: Brian Kearns <[email protected]>
Branch:
Changeset: r71636:9f4587150929
Date: 2014-05-21 16:12 -0400
http://bitbucket.org/pypy/pypy/changeset/9f4587150929/
Log: avoid the call to charpsize2str if size == 0 instead
diff --git a/pypy/module/array/interp_array.py
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -2,7 +2,7 @@
from rpython.rlib import jit
from rpython.rlib.buffer import Buffer
-from rpython.rlib.objectmodel import keepalive_until_here, we_are_translated
+from rpython.rlib.objectmodel import keepalive_until_here
from rpython.rlib.rarithmetic import ovfcheck, widen
from rpython.rlib.unroll import unrolling_iterable
from rpython.rtyper.annlowlevel import llstr
@@ -613,17 +613,11 @@
array._charbuf_stop()
def getslice(self, start, stop, step, size):
+ if size == 0:
+ return ''
if step == 1:
data = self.array._charbuf_start()
try:
- if not we_are_translated():
- # rffi.ptradd(NULL, ...) doesn't work untranslated.
- # It returns nonsense translated, but its return value is
- # unused if size == 0, which is the case if data == NULL
- if self.array._buffer_as_unsigned() == 0:
- assert size == 0
- return ''
-
return rffi.charpsize2str(rffi.ptradd(data, start), size)
finally:
self.array._charbuf_stop()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit