[pypy-commit] pypy typed-cells: (cfbolz, arigo): small code simplification
cfbolz
noreply at buildbot.pypy.org
Tue Aug 11 18:53:10 CEST 2015
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: typed-cells
Changeset: r78924:8c68aa37e287
Date: 2015-08-11 18:53 +0200
http://bitbucket.org/pypy/pypy/changeset/8c68aa37e287/
Log: (cfbolz, arigo): small code simplification
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -306,24 +306,30 @@
from pypy.objspace.std.intobject import W_IntObject
from pypy.objspace.std.floatobject import W_FloatObject
assert not isinstance(w_cell, ObjectMutableCell)
- if isinstance(w_cell, IntMutableCell) and type(w_value) is W_IntObject:
- w_cell.intvalue = w_value.intval
- return None
- if isinstance(w_cell, FloatMutableCell) and type(w_value) is W_FloatObject:
- w_cell.floatvalue = w_value.floatval
- return None
if type(w_value) is W_IntObject:
- if not self.can_contain_mutable_cell:
- self.can_contain_mutable_cell = True
+ if isinstance(w_cell, IntMutableCell):
+ w_cell.intvalue = w_value.intval
+ return None
+ check = self._ensure_can_contain_mutable_cell()
+ assert check
if self.ever_mutated:
return IntMutableCell(w_value.intval)
if type(w_value) is W_FloatObject:
- if not self.can_contain_mutable_cell:
- self.can_contain_mutable_cell = True
+ if isinstance(w_cell, FloatMutableCell):
+ w_cell.floatvalue = w_value.floatval
+ return None
+ check = self._ensure_can_contain_mutable_cell()
+ assert check
if self.ever_mutated:
return FloatMutableCell(w_value.floatval)
return w_value
+ @jit.elidable
+ def _ensure_can_contain_mutable_cell(self):
+ if not self.can_contain_mutable_cell:
+ self.can_contain_mutable_cell = True
+ return True
+
def _copy_attr(self, obj, new_obj):
w_value = self.read(obj, self.selector)
new_obj._get_mapdict_map().add_attr(new_obj, self.selector, w_value)
More information about the pypy-commit
mailing list