Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit vastly simplifies the way .otc parsing is done in font-kit by initializing a font from a descriptor and not copying the buffer. It also makes
Handle
capable of storing an already loaded font, as what happens currently is that we first have a Font which we turn into a Handle (losing track of the Font that was used to create it) only to recreate a font from that same handle (and reparsing the font file in the process). Less waste is good.I've had another stab at it over the weekend at https://github.com/osiewicz/font-kit/pull/new/improve_font_parsing_perf but changes from this PR are way smaller and make more sense IMHO.
improve_font_parsing_perf
tried to deal with issues in font-kit's implementation of otc parsing (it had an accidental O(n^2)), but it couldn't deal with the fact that font-kit had to allocate about 16Gb of memory (kid you not) to parse Iosevka file. :))))) Each 300Mb allocation took about 30ms, and we had to make 54 of those. Quick math: by allocations alone that approach couldn't get below 1.5s for parsing Iosevka, no matter how hard we tried.Meanwhile, on this branch parsing Iosevka takes about 30ms and most of that time is spent.. well.. parsing the font I guess?
I want to let this code sit on Nightly a day or two before releasing it to the Preview.