Skip to content

Commit

Permalink
Cache result of a very frequently computed value
Browse files Browse the repository at this point in the history
  • Loading branch information
abought committed Sep 4, 2020
1 parent 1215912 commit 2fa2ee8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions esm/components/data_layer/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -749,10 +756,14 @@ class BaseDataLayer {
* @returns {string} A dot-delimited string of the format <plot>.<panel>.<data_layer>
*/
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();
}
}

Expand All @@ -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();
Expand Down

0 comments on commit 2fa2ee8

Please sign in to comment.