[pypy-commit] pypy faster-rstruct-2: kill as_str_and_offset_maybe, as it is no longer needed/used anywhere
antocuni
pypy.commits at gmail.com
Fri May 5 06:09:52 EDT 2017
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: faster-rstruct-2
Changeset: r91184:a3cde44d8c93
Date: 2017-05-04 19:26 +0200
http://bitbucket.org/pypy/pypy/changeset/a3cde44d8c93/
Log: kill as_str_and_offset_maybe, as it is no longer needed/used
anywhere
diff --git a/rpython/rlib/buffer.py b/rpython/rlib/buffer.py
--- a/rpython/rlib/buffer.py
+++ b/rpython/rlib/buffer.py
@@ -37,15 +37,6 @@
# May be overridden.
return self.getslice(0, self.getlength(), 1, self.getlength())
- # XXX kill me
- def as_str_and_offset_maybe(self):
- """
- If the buffer is backed by a string, return a pair (string, offset), where
- offset is the offset inside the string where the buffer start.
- Else, return (None, 0).
- """
- return None, 0
-
def getitem(self, index):
"Returns the index'th character in the buffer."
raise NotImplementedError # Must be overriden. No bounds checks.
@@ -113,9 +104,6 @@
def as_str(self):
return self.value
- def as_str_and_offset_maybe(self):
- return self.value, 0
-
def getitem(self, index):
return self.value[index]
@@ -178,12 +166,6 @@
else:
return 0
- def as_str_and_offset_maybe(self):
- string, offset = self.buffer.as_str_and_offset_maybe()
- if string is not None:
- return string, offset+self.offset
- return None, 0
-
def getitem(self, index):
return self.buffer.getitem(self.offset + index)
diff --git a/rpython/rlib/test/test_buffer.py b/rpython/rlib/test/test_buffer.py
--- a/rpython/rlib/test/test_buffer.py
+++ b/rpython/rlib/test/test_buffer.py
@@ -37,31 +37,6 @@
assert s == SomeInteger(nonneg=True)
-def test_as_str_and_offset_maybe():
- buf = StringBuffer('hello world')
- assert buf.as_str_and_offset_maybe() == ('hello world', 0)
- #
- sbuf = SubBuffer(buf, 6, 5)
- assert sbuf.getslice(0, 5, 1, 5) == 'world'
- assert sbuf.as_str_and_offset_maybe() == ('hello world', 6)
- #
- ssbuf = SubBuffer(sbuf, 3, 2)
- assert ssbuf.getslice(0, 2, 1, 2) == 'ld'
- assert ssbuf.as_str_and_offset_maybe() == ('hello world', 9)
- #
- ss2buf = SubBuffer(sbuf, 1, -1)
- assert ss2buf.as_str() == 'orld'
- assert ss2buf.getlength() == 4
- ss3buf = SubBuffer(ss2buf, 1, -1)
- assert ss3buf.as_str() == 'rld'
- assert ss3buf.getlength() == 3
- #
- ss4buf = SubBuffer(buf, 3, 4)
- assert ss4buf.as_str() == 'lo w'
- ss5buf = SubBuffer(ss4buf, 1, -1)
- assert ss5buf.as_str() == 'o w'
- assert ss5buf.getlength() == 3
-
def test_repeated_subbuffer():
buf = StringBuffer('x' * 10000)
for i in range(9999, 9, -1):
More information about the pypy-commit
mailing list