Skip to content

Replace type-id function with lookup table#15904

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
BlobCodes:refactor/type-id-lookup-table
Jul 2, 2025
Merged

Replace type-id function with lookup table#15904
straight-shoota merged 1 commit intocrystal-lang:masterfrom
BlobCodes:refactor/type-id-lookup-table

Conversation

@BlobCodes
Copy link
Contributor

Since #15708 codegen now generates a function mapping type-ids to strings.

This MR replaces this function with a const array, saving ca 7kB of binary size in a hello world application.

That's not really much in crystal terms, but it's simpler and should be easier to use for debugging purposes.

Copy link
Collaborator

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty nice!

@straight-shoota straight-shoota modified the milestone: 1.17.0 Jun 16, 2025
@straight-shoota straight-shoota added this to the 1.17.0 milestone Jun 30, 2025
@straight-shoota straight-shoota merged commit e35977c into crystal-lang:master Jul 2, 2025
39 checks passed
@straight-shoota straight-shoota changed the title refactor: replace type-id function with lookup table Replace type-id function with lookup table Jul 2, 2025
straight-shoota pushed a commit that referenced this pull request Oct 25, 2025
#15904 made every LLVM module that references the `#as` pseudo-method define its own copy of `__crystal_type_id_to_class_name_map`, when only one copy in the main LLVM module is sufficient.

This patch brings the total cache size of the compiler itself from 234 MB to 148 MB on my Windows machine, for example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants