Commit 41c28bcd authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Make a few common cases not use temporary for buffer acquisition

parent 4ee0a2df
...@@ -1227,15 +1227,21 @@ class NameNode(AtomicExprNode): ...@@ -1227,15 +1227,21 @@ class NameNode(AtomicExprNode):
# rhstmp is only used in case the rhs is a complicated expression leading to # rhstmp is only used in case the rhs is a complicated expression leading to
# the object, to avoid repeating the same C expression for every reference # the object, to avoid repeating the same C expression for every reference
# to the rhs. It does NOT hold a reference. # to the rhs. It does NOT hold a reference.
pretty_rhs = isinstance(rhs, NameNode) or rhs.is_temp
if pretty_rhs:
rhstmp = rhs.result_as(self.ctype())
else:
rhstmp = code.funcstate.allocate_temp(self.entry.type, manage_ref=False) rhstmp = code.funcstate.allocate_temp(self.entry.type, manage_ref=False)
buffer_aux = self.entry.buffer_aux
bufstruct = buffer_aux.buffer_info_var.cname
code.putln('%s = %s;' % (rhstmp, rhs.result_as(self.ctype()))) code.putln('%s = %s;' % (rhstmp, rhs.result_as(self.ctype())))
buffer_aux = self.entry.buffer_aux
bufstruct = buffer_aux.buffer_info_var.cname
import Buffer import Buffer
Buffer.put_assign_to_buffer(self.result(), rhstmp, buffer_aux, self.entry.type, Buffer.put_assign_to_buffer(self.result(), rhstmp, buffer_aux, self.entry.type,
is_initialized=not self.lhs_of_first_assignment, is_initialized=not self.lhs_of_first_assignment,
pos=self.pos, code=code) pos=self.pos, code=code)
if not pretty_rhs:
code.putln("%s = 0;" % rhstmp) code.putln("%s = 0;" % rhstmp)
code.funcstate.release_temp(rhstmp) code.funcstate.release_temp(rhstmp)
......
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