Skip to content

Commit

Permalink
fix(perf): fixed massive performance issue in simplification steps fo…
Browse files Browse the repository at this point in the history
…r `Polyline/gonLayer`s (#1991)
  • Loading branch information
JaffaKetchup authored Nov 24, 2024
1 parent 261db40 commit 1150d3b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/src/layer/shared/layer_projection_simplification/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ mixin ProjectionSimplificationManagement<
///
/// Do not use before invoking [build]. Only necessarily up to date directly
/// after [build] has been invoked.
late Iterable<ProjectedElement> simplifiedElements;
late List<ProjectedElement> simplifiedElements;

Iterable<ProjectedElement>? _cachedProjectedElements;
final _cachedSimplifiedElements = <int, Iterable<ProjectedElement>>{};
List<ProjectedElement>? _cachedProjectedElements;
final _cachedSimplifiedElements = <int, List<ProjectedElement>>{};

double? _devicePixelRatio;

Expand Down Expand Up @@ -89,12 +89,12 @@ mixin ProjectionSimplificationManagement<
}

simplifiedElements =
(_cachedSimplifiedElements[camera.zoom.floor()] ??= _simplifyElements(
_cachedSimplifiedElements[camera.zoom.floor()] ??= _simplifyElements(
camera: camera,
projectedElements: projected,
pixelTolerance: widget.simplificationTolerance,
devicePixelRatio: newDPR,
));
).toList(growable: false);
}

return Builder(
Expand Down

0 comments on commit 1150d3b

Please sign in to comment.