Commit c106c4ab authored by Stefan Behnel's avatar Stefan Behnel

use simple memcpy() instead of explicit C array copying

parent bc3667ab
...@@ -4072,30 +4072,13 @@ class SliceIndexNode(ExprNode): ...@@ -4072,30 +4072,13 @@ class SliceIndexNode(ExprNode):
else: else:
array_length = '%s - %s' % (self.stop_code(), start_offset) array_length = '%s - %s' % (self.stop_code(), start_offset)
def copy_carray(dst, src, item_type, start, count, depth): code.globalstate.use_utility_code(UtilityCode.load_cached("IncludeStringH", "StringTools.c"))
var_name = Naming.quick_temp_cname code.putln("memcpy(&(%s[%s]), %s, sizeof(%s[0]) * (%s));" % (
if depth: self.base.result(), start_offset,
var_name += str(depth) rhs.result(),
dst_item, src_item = '{dst}[{i}+{start}] = {src}[{i}]'.format( self.base.result(), array_length
src=src, ))
dst=dst,
start=start,
i=var_name
).split(' = ')
code.putln('{')
code.putln('Py_ssize_t %s;' % var_name)
code.put('for ({i}=0; {i} < {count}; {i}++) '.format(
i=var_name,
count=count))
if item_type.is_array:
copy_carray(dst_item, src_item, item_type.base_type, 0, item_type.size, depth + 1)
else:
code.putln('%s = %s;' % (dst_item, src_item))
code.putln('}')
copy_carray(self.base.result(), rhs.result(), rhs.type.base_type,
start_offset, array_length, 0)
self.generate_subexpr_disposal_code(code) self.generate_subexpr_disposal_code(code)
self.free_subexpr_temps(code) self.free_subexpr_temps(code)
rhs.generate_disposal_code(code) rhs.generate_disposal_code(code)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment