Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Use classes instead of Records for efficiency #1769

Open
josxha opened this issue Dec 10, 2023 · 3 comments
Open

[FEATURE] Use classes instead of Records for efficiency #1769

josxha opened this issue Dec 10, 2023 · 3 comments
Assignees
Labels
feature This issue requests a new feature P: 3 (low) (Default priority for feature requests) S: core Scoped to the core flutter_map functionality
Milestone

Comments

@josxha
Copy link
Contributor

josxha commented Dec 10, 2023

The research in #1750 (comment) and #1750 (comment) points out the reasons to avoid records.
Records have no advantage on memory consumtion while they require about double the time to be initialized.

As a consequence we should remove records from the package and use immutable classes in favour of it.

@josxha josxha self-assigned this Dec 10, 2023
@josxha josxha added the general This issue is not a bug nor feature request, and is better suited for Discussions or Discord label Dec 10, 2023
@josxha josxha added this to the v7.0 milestone Dec 10, 2023
@JaffaKetchup JaffaKetchup changed the title [REFACTOR] Turn records into classes [FEATURE] Use classes instead of Records for efficiency Dec 10, 2023
@JaffaKetchup JaffaKetchup added feature This issue requests a new feature P: 2 (soon™?) S: core Scoped to the core flutter_map functionality and removed general This issue is not a bug nor feature request, and is better suited for Discussions or Discord labels Dec 10, 2023
@monsieurtanuki
Copy link
Contributor

@josxha That would include this one in Projection:

  (double, double) projectXY(LatLng latlng);

Would definitely be a breaking change, but would hopefully bring better performances. Something like that?

  DoublePoint projectDoublePoint(LatLng latlng);

Instead of redundant code like this one:

  _ProjectedPolygon._fromPolygon(Projection projection, Polygon<R> polygon)
      : this._(
          polygon: polygon,
          points: List<DoublePoint>.generate(
            polygon.points.length,
            (j) {
              final (x, y) = projection.projectXY(polygon.points[j]);
              return DoublePoint(x, y);
            },

@monsieurtanuki
Copy link
Contributor

@josxha For the record I've just tried to replace (double, double) methods with Offset in class Crs (which eventually impacted a dozen of classes).
I cannot say that there was that much impact on performances using Offset instead of (double, double), in a first approach, using the "Polyline Stress Test" in profile mode (raster then UI, in ms):

x old solid algo new solid algo
offset 203.4 + 43.6 556.2 + 54.6
(double, double) 206.2 + 42.1 578.9 + 53.2

For next tests:

  • profile mode
  • "Polyline Stress Test"
  • zoom 5 times around "Valence, France"
  • slider to the left

Something like that:
Screenshot_20240507_131710

@JaffaKetchup
Copy link
Member

I will say that I don't think this is top priority. This is quite a level of micro-optimization!

@JaffaKetchup JaffaKetchup added P: 3 (low) (Default priority for feature requests) and removed P: 2 (soon™?) labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue requests a new feature P: 3 (low) (Default priority for feature requests) S: core Scoped to the core flutter_map functionality
Projects
Status: To do
Development

No branches or pull requests

3 participants