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

Fix an overflow bug in the text measurement cache #44

Merged
merged 3 commits into from
Oct 15, 2024

Conversation

nicbarker
Copy link
Owner

To address #43 πŸ„β€β™‚οΈ
I simply forgot to implement a mechanism for clearing stale items from the text measurement cache 🀦
This PR introduces a "generation" mechanism for clearing items from the text measurement cache. The TL;DR is:

  • A generation integer is assigned to text measurement cache items every time they are accessed
  • When walking the linked lists of hash map items, any items passed over that are more than a few generations old will be ejected.
  • If the measurement cache fills up completely (possible in some circumstances where hashes are very evenly distributed, a TODO here is to figure out ideal bucket size to stop this from happening), just remeasure the text dimensions on the fly (obviously much slower, but shouldn't theoretically occur more than a few times in a frame under the worst circumstances)

@nicbarker nicbarker merged commit 3dffbea into main Oct 15, 2024
3 checks passed
@nicbarker nicbarker deleted the 012-fix-text-cache-overflow branch October 16, 2024 00:33
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.

1 participant