-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Batch mode for efficiently mutating Style instances
Mutation operations on a Style instance are designed to be atomic. Depending on the operation, there is a significant amount of work that must be preformed to flush and recreate state. This work is wasted when multiple mutation methods are invokes sequentially. Batching these mutations allows deferring this work until the batch is complete and deduping the work. style.batch(function() { style.addLayer(layer1); style.addLayer(layer2); ... style.addLayer(layerN); }); Internally, calls to four methods are deferred: - style._groupLayers (will only fire once) - style._broadcastLayers (will only fire once) - style._reloadSource (will fire once per source) - style.fire (each call will fire) A casual benchmark shows the time to add 80 layers dropping from ~800 ms to ~20 ms when run as a batch. Issue: #1341
- Loading branch information
Showing
3 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters