From d6ff03fc8b3d0bfedd568dbae0b67f0901e35834 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 21 Jan 2024 13:06:17 +0100 Subject: [PATCH] Add more comments on the internal nature of types and explicitly annotate CrsWithStaticTransformation as internal. --- lib/flutter_map.dart | 2 +- lib/src/geo/crs.dart | 2 ++ lib/src/misc/offsets.dart | 1 + lib/src/misc/simplify.dart | 14 ++++++++------ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 15adc1280..7cb3fa6e9 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -16,7 +16,7 @@ /// * discord.gg: library flutter_map; -export 'package:flutter_map/src/geo/crs.dart'; +export 'package:flutter_map/src/geo/crs.dart' hide CrsWithStaticTransformation; export 'package:flutter_map/src/geo/latlng_bounds.dart'; export 'package:flutter_map/src/gestures/interactive_flag.dart'; export 'package:flutter_map/src/gestures/latlng_tween.dart'; diff --git a/lib/src/geo/crs.dart b/lib/src/geo/crs.dart index 80963a862..89fe1b9d1 100644 --- a/lib/src/geo/crs.dart +++ b/lib/src/geo/crs.dart @@ -58,7 +58,9 @@ abstract class Crs { Bounds? getProjectedBounds(double zoom); } +/// Internal base class for CRS with a single zoom-level independent transformation. @immutable +@internal abstract class CrsWithStaticTransformation extends Crs { @nonVirtual @protected diff --git a/lib/src/misc/offsets.dart b/lib/src/misc/offsets.dart index 10a6447bd..050994651 100644 --- a/lib/src/misc/offsets.dart +++ b/lib/src/misc/offsets.dart @@ -1,6 +1,7 @@ import 'dart:ui'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map/src/geo/crs.dart'; import 'package:flutter_map/src/misc/simplify.dart'; import 'package:latlong2/latlong.dart'; diff --git a/lib/src/misc/simplify.dart b/lib/src/misc/simplify.dart index f6520e306..b3573adba 100644 --- a/lib/src/misc/simplify.dart +++ b/lib/src/misc/simplify.dart @@ -7,13 +7,15 @@ import 'package:flutter_map/src/geo/crs.dart'; import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; -// Custom point due to math.Point being slow. Math operations tend to -// have 20+x penalty for virtual function overhead given the reified nature of -// Dart generics. +/// Internal double-precision point/vector implementation not to be used in publicly. +/// +/// This is an optimization. Vector operations on math.Point tend to incur a 20+x +/// penalty due to virtual function overhead caused by reified generics. +/// +/// Further note that unlike math.Point, members are mutable to allow object reuse/pooling +/// and therefore reduce GC pressure. @internal -class DoublePoint { - // Note: Allow mutability for reuse/pooling to reduce GC pressure and increase performance. - // Geometry operations should be safe-by-default to avoid accidental bugs. +final class DoublePoint { double x; double y;