Skip to content

Commit

Permalink
use the new function in ''.join(list_of_chars) and for bytearrays
Browse files Browse the repository at this point in the history
unfortunately the performance doesn't make sense
  • Loading branch information
cfbolz committed Jan 27, 2024
1 parent ddbd466 commit 30e2044
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pypy/objspace/std/bytearrayobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from rpython.rlib.objectmodel import (
import_from_mixin, newlist_hint, resizelist_hint, specialize)
from rpython.rlib.rstring import StringBuilder, ByteListBuilder
from rpython.rlib.rstring import charlist_slice_to_str
from rpython.rlib.debug import check_list_of_chars, check_nonneg
from rpython.rtyper.lltypesystem import rffi
from rpython.rlib.rgc import (resizable_list_supporting_raw_ptr,
Expand Down Expand Up @@ -57,7 +58,7 @@ def writebuf_w(self, space):
return BytearrayBuffer(self)

def charbuf_w(self, space):
return ''.join(self.getdata())
return charlist_slice_to_str(self._data, self._offset)

def bytearray_list_of_chars_w(self, space):
return self.getdata()
Expand Down
6 changes: 2 additions & 4 deletions rpython/rtyper/lltypesystem/rstr.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,10 @@ def ll_join_strs(length, items, TYP):
@staticmethod
@jit.look_inside_iff(lambda length, chars, RES: jit.isconstant(length) and jit.isvirtual(chars))
def ll_join_chars(length, chars, RES):
# no need to optimize this, will be replaced by string builder
# at some point soon
from rpython.rlib.rstring import ll_charlist_slice_to_str
num_chars = length
if RES is StringRepr.lowleveltype:
target = Char
malloc = mallocstr
return ll_charlist_slice_to_str(chars, 0, length)
else:
target = UniChar
malloc = mallocunicode
Expand Down

0 comments on commit 30e2044

Please sign in to comment.