Skip to content

Commit

Permalink
Add more comments on the internal nature of types and explicitly anno…
Browse files Browse the repository at this point in the history
…tate CrsWithStaticTransformation as internal.
  • Loading branch information
ignatz committed Jan 21, 2024
1 parent 9e07d1f commit d6ff03f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/flutter_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/// * discord.gg: <https://discord.gg/BwpEsjqMAH>
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';
Expand Down
2 changes: 2 additions & 0 deletions lib/src/geo/crs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ abstract class Crs {
Bounds<double>? getProjectedBounds(double zoom);
}

/// Internal base class for CRS with a single zoom-level independent transformation.
@immutable
@internal
abstract class CrsWithStaticTransformation extends Crs {
@nonVirtual
@protected
Expand Down
1 change: 1 addition & 0 deletions lib/src/misc/offsets.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
14 changes: 8 additions & 6 deletions lib/src/misc/simplify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> 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;

Expand Down

0 comments on commit d6ff03f

Please sign in to comment.