From 54b20c02683556aad22697bb374f0a7b0cd735ed Mon Sep 17 00:00:00 2001 From: Samuel Asensi Date: Sat, 13 Oct 2018 19:53:45 +0200 Subject: [PATCH] Improve global matrix cache invalidation performance (#1563) --- src/item/Item.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/item/Item.js b/src/item/Item.js index 99b933b9..199ec542 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1247,12 +1247,20 @@ new function() { // Injection scope for various item event handlers // If there's a cached global matrix for this item, check if all its // parents also have one. If it's missing in any of its parents, it // means the child's cached version isn't valid anymore. + // For better performance, we also use the occasion of this loop to + // clear cached version of items parents. var parent = this._parent; + var parents = []; while (parent) { if (!parent._globalMatrix) { matrix = null; + // Also clear global matrix of item's parents. + for (var i = 0, l = parents.length; i < l; i++) { + parents[i]._globalMatrix = null; + } break; } + parents.push(parent); parent = parent._parent; } }