Commit 2b2db5cb authored by Julien Muchembled's avatar Julien Muchembled

amount_generator: speed up property initialization of generated amounts

By default, Base._edit first tests each property with getProperty, not to
modify the object when values don't change. Here, getProperty costs a lot
(in particular for categories) and rarely/never avoids the use of setters.

So here, the main gain is to do something like _edit(force_update=1).
As an additional small optimization, we directly use _setProperty instead of
_edit. We also stop copying int_index from the Amount Generator Line because
it's not useful enough:
- float_index may be used instead
- or dependency-based sorting is enough
- as a last resort, properties can be fetched directly from the causality
  value, or dynamically with asPredicate and mapped_value_property_list
parent 706878b9
......@@ -477,13 +477,11 @@ class AmountGeneratorMixin:
amount._setCategoryList(property_dict.pop('category_list', ()))
if amount.getQuantityUnit():
del property_dict['quantity_unit']
amount._edit(
quantity=quantity,
# XXX Are title, int_index and description useful ??
title=self.getTitle(),
int_index=self.getIntIndex(),
description=self.getDescription(),
**property_dict)
amount._setQuantity(quantity)
amount._setTitle(self.getTitle())
amount._setDescription(self.getDescription())
for x in property_dict.iteritems():
amount._setProperty(*x)
# convert to default management unit if possible
amount._setQuantity(amount.getConvertedQuantity())
amount._setQuantityUnit(amount.getResourceDefaultQuantityUnit())
......
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