summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-05-05 06:50:59 +0200
committerGéry Debongnie <ged@odoo.com>2017-05-07 22:38:27 +0200
commitc75680c527844b3b984fa6dfbe04b612528cd9fb (patch)
tree657c8ccbd11bf5f632c44a2e79da3379f13e5b30 /addons/web/static/src/js/fields
parent9d7b421b8c2f35ed61d21fad87291b1760bb7ded (diff)
[REF] web: optimize basic model (improve perfs for most views)
The 'get' method in the basic model is called very often (too often, but that is another issue). For a large list with many columns, it can be quickly be called more than 10k times. In that function, we had to protect our integrity by performing a deep clone with $.extend, so noone else can be allowed to change something in our internal structure. This is good in theory, but not so good in practice, as $.extend is a really expensive operation. Also, we try to have the smallest external API by deleting useless keys. But instead of keeping a blacklist of private keys, it is simpler to have a whitelist of public keys. So, what we do is to explicitely construct the object returned by key, since we know the types of every values involved. This is more explicit, and at the same time, much faster. Also, we propagate the options for elements of type list. This is why I had to change the isFieldSet method. In a benchmark I just ran, loading and rendering a large list (200 rows, 7 columns) went from about 2.7s to 0.7s. We still do way too much work, but at least it is much faster...
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/abstract_field.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js
index b78e0b3e28b..5e972f647e6 100644
--- a/addons/web/static/src/js/fields/abstract_field.js
+++ b/addons/web/static/src/js/fields/abstract_field.js
@@ -87,7 +87,7 @@ var AbstractField = Widget.extend({
// the 'attrs' property contains the attributes of the xml 'field' tag,
// the inner views...
var fieldsInfo = record.fieldsInfo[this.viewType];
- this.attrs = fieldsInfo && fieldsInfo[name] || {};
+ this.attrs = options.attrs || (fieldsInfo && fieldsInfo[name]) || {};
// this property tracks the current (parsed if needed) value of the field.
// Note that we don't use an event system anymore, using this.get('value')