Skip to content

Conversation

@mootw
Copy link
Contributor

@mootw mootw commented Dec 2, 2024

This will yield significant performance benefits due to a reduction in casting. This likely breaks the external API but it is worth it

Migrations:
Point<double> -> Offset or Size
Bounds<double> -> Rect
Bounds<int> -> (rename and marked internal) IntegerBounds

maybe fixes #1769 (it is not a full migration, as there are still record types (they are okay in certain conditions honestly, especially as an interface between public apis), but it does fix a TON of issues with math.Point, which is much slower than the difference between Objects and Records)

there is a modest 7% performance boost in the polygon and polyline tests in both the UI and Raster threads in my debug mode profiling. i expect other layers to benefit and more performance boost in ideal situations

@mootw mootw marked this pull request as ready for review December 3, 2024 00:41
@mootw mootw requested a review from a team December 3, 2024 03:02
Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things I would be even more heavy handed/breaking on. I would be in favour of implemented deprecated methods just to ease the transition for external users, but I think we need to be more thorough.

Is there any reason for keeping Bounds using Point?

JaffaKetchup

This comment was marked as duplicate.

@JaffaKetchup JaffaKetchup changed the title Migrate to use Offset internally feat!: migrate Point<double> to Offset internally Dec 3, 2024
@mootw
Copy link
Contributor Author

mootw commented Dec 3, 2024

Some things I would be even more heavy handed/breaking on. I would be in favour of implemented deprecated methods just to ease the transition for external users, but I think we need to be more thorough.

Is there any reason for keeping Bounds using Point?

Yes, I have only migrated the Point interface methods in Bounds because the DiscreteTileRange uses Bounds<int> which would mean that i need to implement a new IntegerBounds class on top of migrating Bounds or change DiscreteTileRange to no longer require integers

@mootw mootw requested review from a team and josxha December 5, 2024 08:26
Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple things left, mostly nits.

@mootw mootw requested a review from JaffaKetchup December 5, 2024 16:54
Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉. Performance seems to have improved (about 0.2ms on home page example app, 0.3-0.4ms on basic polygon page, untested others), enough to actually make things feel slightly smoother (but maybe that's just a placebo). Don't notice any bugs, and code looks good.

Copy link
Contributor

@josxha josxha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes. 😄
Maybe a feature release would be good before merging breaking changes?

Edit: I wouldn't be sad if we'd not use records here, but pr is fine as is too. (:

final (minx, miny) =
        transformation.transform(b.min.dx, b.min.dy, zoomScale);
    final (maxx, maxy) =
        transformation.transform(b.max.dx, b.max.dy, zoomScale);

@mootw
Copy link
Contributor Author

mootw commented Dec 5, 2024

i like that for future changes. I want to avoid creeping scope on this PR too much for now. we could wait to release for more changes

@mootw mootw merged commit 60d9846 into fleaflet:master Dec 5, 2024
7 checks passed
@mootw mootw deleted the convert-to-offset branch December 5, 2024 22:27
? (point - (camera.nonRotatedSize / 2.0))
: Point(offset!.dx, offset.dy))
.rotate(camera.rotationRad);
final rotationCenter = (camera.projectAtZoom(camera.center) + offset!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hket-tommyluk,
Sorry if we've made a mistake! Can you please file a bug report if this is causing an issue and we'll look into it. I'm not clear what this would cause.

tobesucht added a commit to tobesucht/flutter_map_supercluster that referenced this pull request Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Use classes instead of Records for efficiency

4 participants