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

Improve performance by optimizing glyph lookup #3855

Merged
merged 11 commits into from
Nov 11, 2024

Conversation

brdvd
Copy link
Contributor

@brdvd brdvd commented Nov 9, 2024

This PR improves the total runtime by optimizing the glyph lookup in resources. Some runtime data with a few pieces of different size:

Number of pages Runtime before in s Runtime after in s  Improvement in %
3 0.306 0.260 15
10 1.732 1.525 12
97 4.339 3.963 9

Note that after adding the possibility to use several fonts simultaneously, glyph lookup now involves two maps: one for loaded fonts and one for the glyph itself. Changes in this PR:

  • We optimize the number of map lookups, mostly by replacing map::contains followed by map::at with a single map::find.
  • We cache the glyph that was looked up last. This is helpful, since often the same glyph is requested several times consecutively, e.g. from calls of GetGlyphWidth and GetGlyphHeight.
  • There are a few other (minor) code improvements in Resources.

@lpugin lpugin merged commit c87b3d6 into rism-digital:develop Nov 11, 2024
5 checks passed
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.

2 participants