-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Don't copy Glyph on GlyphCache hit #6954
base: master
Are you sure you want to change the base?
Conversation
The Glyph is being passed around by reference, so doing the copy is not desired.
@@ -192,72 +200,92 @@ impl GlyphCache { | |||
&mut self, | |||
glyph_key: GlyphKey, | |||
loader: &mut L, | |||
show_missing: bool, | |||
) -> Glyph | |||
) -> Result<&Glyph, Box<RasterizerError>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error happens once per glyph key, so to not enlarge the return value we simply box the value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What inspired this change? Saying this is a bit ugly compared to the current code is an understatement, so there should be some good justification.
The glyph is ~32 bytes and we copy it for each cell, so if we assume 77 * 180 cells we copy 400 KB of data for no reason for each frame, given that we only use a reference, and not the copy. And with my code we copy 4x less, so it's simply faster? |
I'm pretty sure our |
Says who? Unless you've benchmarked it, it's not faster. Making the code more complicated if there's no real world benefit to it isn't useful. |
The Glyph is being passed around by reference, so doing the copy is not desired.
--
It might look ugly a bit given that missing glyph handling must be moved, but it's actually
don't try to copy lots of glyph data around on each renderer call.