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: ...@@ -477,13 +477,11 @@ class AmountGeneratorMixin:
amount._setCategoryList(property_dict.pop('category_list', ())) amount._setCategoryList(property_dict.pop('category_list', ()))
if amount.getQuantityUnit(): if amount.getQuantityUnit():
del property_dict['quantity_unit'] del property_dict['quantity_unit']
amount._edit( amount._setQuantity(quantity)
quantity=quantity, amount._setTitle(self.getTitle())
# XXX Are title, int_index and description useful ?? amount._setDescription(self.getDescription())
title=self.getTitle(), for x in property_dict.iteritems():
int_index=self.getIntIndex(), amount._setProperty(*x)
description=self.getDescription(),
**property_dict)
# convert to default management unit if possible # convert to default management unit if possible
amount._setQuantity(amount.getConvertedQuantity()) amount._setQuantity(amount.getConvertedQuantity())
amount._setQuantityUnit(amount.getResourceDefaultQuantityUnit()) 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