Repository navigation
Conversation
bin2header.cmake looped per byte and re-expanded the full hex string each iteration (O(n^2)), so the build appeared stuck on the bundled font. Replace the loop with two regex passes. Byte values and order are preserved: the first pass rewrites each hex pair in place as 0xNN,, and the second only inserts a newline and indent after every 12 entries. The only output differences are whitespace and a trailing comma, which is valid C.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #16
bin2header.cmakeiterated once per byte and expanded the full hexstring each time (O(n^2)). For the bundled font, the build appeared to
hang; the old script did not finish when I cancelled it.
This replaces the loop with two
string(REGEX REPLACE)passes:file(READ ... HEX)is rewritten in place as0xNN,. Pairs are replaced independently, so values and order areunchanged.
It adds whitespace only.
The script's interface (
INPUT,OUTPUT,ARRAY_NAME) is unchanged,so
CMakeLists.txtandmain.care untouched. Only commands availablein CMake 3.19+ are used, and comments explain why, per AGENTS.md.
Output differs from the old script only in whitespace and a trailing
comma after the last element, which is valid C.
Tested:
cmake -B build -G Ninja && cmake --build buildsucceeds (Debug)cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build buildsucceeds, and./build/ghostlingrunsstripping whitespace and the trailing comma
Note: running the Debug build (
./build/ghostling) panics with"incorrect alignment" in libghostty's
ghostty_terminal_set. This isoutside this change (
main.cand libghostty are untouched).