From 514aaab8174e73629b90d6e1a8e137f586cb9ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20Zag=C3=B3rski?= <1507542+zbigg@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:44:19 +0200 Subject: [PATCH] carto: RasterLayer fix perf issue caused by spurious data changes (#9218) --- modules/carto/src/layers/raster-layer.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/carto/src/layers/raster-layer.ts b/modules/carto/src/layers/raster-layer.ts index e6afb88fb5c..6657b3d2a4a 100644 --- a/modules/carto/src/layers/raster-layer.ts +++ b/modules/carto/src/layers/raster-layer.ts @@ -77,6 +77,15 @@ type _RasterLayerProps = { tileIndex: bigint; }; +type RasterColumnLayerData = { + data: Raster; + length: number; +}; + +function wrappedDataComparator(oldData: RasterColumnLayerData, newData: RasterColumnLayerData) { + return oldData.data === newData.data && oldData.length === newData.length; +} + // Adapter layer around RasterColumnLayer that converts data & accessors into correct format export default class RasterLayer extends CompositeLayer< Required> & ExtraProps @@ -125,6 +134,7 @@ export default class RasterLayer extends Composite data, // Pass through data for getSubLayerAccessor() length: blockSize * blockSize }, + dataComparator: wrappedDataComparator, offset, highlightedObjectIndex, highlightColor