diff options
| author | Gery Debongnie <ged@openerp.com> | 2014-04-09 16:57:35 +0200 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2014-04-09 16:57:35 +0200 |
| commit | f966931b879a1ed3cdc54b644c2e73456244c201 (patch) | |
| tree | 17426968b56c6f0b61742e69f4923b5c0173051c /addons/web_graph/static/src/js/pivot_table.js | |
| parent | 281c19a751be815f353cbda10c09ac055e5d9594 (diff) | |
[IMP] performance improvement: write a custom isEqual function to use instead of _.isEqual to make the code faster in graph view (isEqual was determined guilty of being slow by profiling on a large view) (addon web_graph)
bzr revid: ged@openerp.com-20140409145735-m21t2fzmaepr1hsa
Diffstat (limited to 'addons/web_graph/static/src/js/pivot_table.js')
| -rw-r--r-- | addons/web_graph/static/src/js/pivot_table.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js index 6fc9cf2b12b..6b12829982e 100644 --- a/addons/web_graph/static/src/js/pivot_table.js +++ b/addons/web_graph/static/src/js/pivot_table.js @@ -281,7 +281,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ var row_value = (prefix || []).concat(data_pt.attributes.value.slice(0,index)); var col_value = data_pt.attributes.value.slice(index); - if (expand && !_.find(col_headers, function (hdr) {return _.isEqual(col_value, hdr.path);})) { + if (expand && !_.find(col_headers, function (hdr) {return self.isEqual(col_value, hdr.path);})) { return; } var row = self.find_or_create_header(row_headers, row_value, data_pt); @@ -311,8 +311,9 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ }, find_or_create_header: function (headers, path, data_pt) { + var self = this; var hdr = _.find(headers, function (header) { - return _.isEqual(path, header.path); + return self.isEqual(path, header.path); }); if (hdr) { return hdr; @@ -328,7 +329,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ title: _t(_.last(path)) }); var parent = _.find(headers, function (header) { - return _.isEqual(header.path, _.initial(path, 1)); + return self.isEqual(header.path, _.initial(path, 1)); }); var previous = parent.children.length ? _.last(parent.children) : parent; @@ -360,10 +361,11 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ // set the 'expanded' status of new_headers more or less like root.headers, with root as root set_headers: function(new_headers, root) { + var self = this; if (root.headers) { _.each(root.headers, function (header) { var corresponding_header = _.find(new_headers, function (h) { - return _.isEqual(h.path, header.path); + return self.isEqual(h.path, header.path); }); if (corresponding_header && header.expanded) { corresponding_header.expanded = true; @@ -431,6 +433,16 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ return field.split(':')[0]; }, + isEqual: function (path1, path2) { + if (path1.length !== path2.length) { return false; } + for (var i = 0; i < path1.length; i++) { + if (path1[i] !== path2[i]) { + return false; + } + } + return true; + }, + }); })(); |
