From 2fa2ee8adc711e49ccb221353ce101f8d90562c9 Mon Sep 17 00:00:00 2001 From: Andy Boughton Date: Fri, 4 Sep 2020 13:04:25 -0400 Subject: [PATCH] Cache result of a very frequently computed value --- esm/components/data_layer/base.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/esm/components/data_layer/base.js b/esm/components/data_layer/base.js index f8fd4fda..9e03976b 100644 --- a/esm/components/data_layer/base.js +++ b/esm/components/data_layer/base.js @@ -43,12 +43,19 @@ class BaseDataLayer { this.layout_idx = null; /** - * The unique identifier for this layer. Should be unique within this layer. + * The unique identifier for this layer. Should be unique within this panel. * @public * @member {String} */ this.id = null; + /** + * The fully qualified identifier for the data layer, prefixed by any parent or container elements. + * @type {string} + * @private + */ + this._base_id = null; + /** * @protected * @member {Panel} @@ -749,10 +756,14 @@ class BaseDataLayer { * @returns {string} A dot-delimited string of the format .. */ getBaseId () { + if (this._base_id) { + return this._base_id; + } + if (this.parent) { return `${this.parent_plot.id}.${this.parent.id}.${this.id}`; } else { - return ''; + return this.id.toString(); } } @@ -775,6 +786,7 @@ class BaseDataLayer { * @returns {BaseDataLayer} */ initialize() { + this._base_id = this.getBaseId(); // Append a container group element to house the main data layer group element and the clip path const base_id = this.getBaseId();