Skip to content

Skip checked enum inits in cycle() hot path - #891

Open
natecook1000 wants to merge 1 commit into
mainfrom
perf/simplify-cycle
Open

natecook1000 wants to merge 1 commit into
mainfrom
perf/simplify-cycle

Conversation

@natecook1000

Copy link
Copy Markdown
Member

The generated checked initializers for raw representable enums are too big to be inlined into the large cycle() function. Since the only values used in cycle() are raw values generated from cases in the first place, and these enums have raw case values that match the enum tag, it's safe to bitcast from the raw value to the enum type instead.

This change adds a function to convert a raw value to an enum case, asserting in debug mode if the constructed case is invalid.

The generated checked initializers for raw representable enums
are too big to be inlined into the large `cycle()` function. Since
the only values used in `cycle()` are raw values generated from
cases in the first place, and these enums have raw case values
that match the enum tag, it's safe to bitcast from the raw value
to the enum type instead.

This change adds a function to convert a raw value to an enum
case, asserting in debug mode if the constructed case is invalid.
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.

1 participant