-
Notifications
You must be signed in to change notification settings - Fork 219
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
Compile string constants into unique.Handle[string] #1018
Comments
It's an interesting feature. I imagine it'd be most useful for literals and the AST. Is that what you have in mind as well? Or something else? |
Yes, exactly that. In my experience, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature request checklist
Change
Go 1.23 added support for internalizing strings with a standard API (https://pkg.go.dev/unique). When compiling an expression, the AST could store string constants as
unique.Handle[string]
. Conversion to a normal string could happen on the fly.Example
I'm implementing a custom map with strings as key:
With unique strings, the map becomes more efficient.
Alternatives considered
A normal string extracted from CEL could be turned into a handle before looking it up in a map which uses internalized strings. But that causes overhead during each evaluation which could be moved into the one-time compilation.
The text was updated successfully, but these errors were encountered: