[pypy-commit] pypy py3k-memoryview: avoid the call to charpsize2str if size == 0 instead
bdkearns
noreply at buildbot.pypy.org
Thu May 22 04:32:23 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch: py3k-memoryview
Changeset: r71667:a73e8f64db11
Date: 2014-05-21 16:12 -0400
http://bitbucket.org/pypy/pypy/changeset/a73e8f64db11/
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
@@ -653,17 +653,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()
More information about the pypy-commit
mailing list