Skip to content

Commit

Permalink
carto: RasterLayer fix perf issue caused by spurious data changes (#9218
Browse files Browse the repository at this point in the history
)
  • Loading branch information
zbigg authored and donmccurdy committed Oct 24, 2024
1 parent 3ac6876 commit 514aaab
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/carto/src/layers/raster-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataT = any, ExtraProps = {}> extends CompositeLayer<
Required<RasterLayerProps<DataT>> & ExtraProps
Expand Down Expand Up @@ -125,6 +134,7 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
data, // Pass through data for getSubLayerAccessor()
length: blockSize * blockSize
},
dataComparator: wrappedDataComparator,
offset,
highlightedObjectIndex,
highlightColor
Expand Down

0 comments on commit 514aaab

Please sign in to comment.