Skip to content

Commit

Permalink
Cache serialized layers
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhamley committed Feb 12, 2020
1 parent 64ca426 commit 6ae5e0c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class Style extends Evented {
_request: ?Cancelable;
_spriteRequest: ?Cancelable;
_layers: {[string]: StyleLayer};
_serializedLayers: {[string]: Object};
_order: Array<string>;
sourceCaches: {[string]: SourceCache};
zoomHistory: ZoomHistory;
Expand Down Expand Up @@ -149,6 +150,7 @@ class Style extends Evented {
this.crossTileSymbolIndex = new CrossTileSymbolIndex();

this._layers = {};
this._serializedLayers = {};
this._order = [];
this.sourceCaches = {};
this.zoomHistory = new ZoomHistory();
Expand Down Expand Up @@ -262,10 +264,12 @@ class Style extends Evented {
this._order = layers.map((layer) => layer.id);

this._layers = {};
this._serializedLayers = {};
for (let layer of layers) {
layer = createStyleLayer(layer);
layer.setEventedParent(this, {layer: {id: layer.id}});
this._layers[layer.id] = layer;
this._serializedLayers[layer.id] = layer.serialize();
}
this.dispatcher.broadcast('setLayers', this._serializeLayers(this._order));

Expand Down Expand Up @@ -1078,10 +1082,6 @@ class Style extends Evented {
}

const sourceResults = [];
const serializedLayers = {};
for (const layer in this._layers) {
serializedLayers[layer] = this._layers[layer].serialize();
}

params.availableImages = this.imageManager.listImages();

Expand All @@ -1091,7 +1091,7 @@ class Style extends Evented {
queryRenderedFeatures(
this.sourceCaches[id],
this._layers,
serializedLayers,
this._serializedLayers,
queryGeometry,
params,
transform)
Expand All @@ -1104,7 +1104,7 @@ class Style extends Evented {
sourceResults.push(
queryRenderedSymbols(
this._layers,
serializedLayers,
this._serializedLayers,
this.sourceCaches,
queryGeometry,
params,
Expand Down

0 comments on commit 6ae5e0c

Please sign in to comment.