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

Avoid allocating for each binding trigger #5490

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Jacalz
Copy link
Member

@Jacalz Jacalz commented Feb 2, 2025

Description:

This reworks data listeners for bindings to be a bit smarter. Instead of using a map (with unnecessary bool parameter) to store the listener, we just use a regular slice. We iterate over this slice in the queued operation without needing to append to a new slice first. Delete is a bit more expensive (and more code because with don't use Go 1.21 yet and can't use the slices package) but add is the one that is more common and trigger is the most common so it makes sense to optimise for the common path. A second lock is needed to not deadlock tests for some reason and it also avoids contention between value updates.

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

@Jacalz Jacalz requested a review from dweymouth February 4, 2025 20:21
@coveralls
Copy link

Coverage Status

coverage: 62.649% (+0.03%) from 62.615%
when pulling 0d99434 on Jacalz:binding-trigger-faster
into 739f0e6 on fyne-io:develop.

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.

3 participants