Skip to content
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

String interning for map[string] keys (feature proposal) #403

Open
klpx opened this issue Oct 3, 2024 · 0 comments
Open

String interning for map[string] keys (feature proposal) #403

klpx opened this issue Oct 3, 2024 · 0 comments

Comments

@klpx
Copy link

klpx commented Oct 3, 2024

Hi! It is great, that easyjson has an option to intern strings:

type Foo struct {
  UUID  string `json:"uuid"`         // will not be interned during unmarshaling
  State string `json:"state,intern"` // will be interned during unmarshaling
}

But the another common target for interning might be actually a string key in arbitrary map[string], because sometimes keys are same, but there is also just a few of them.

type User struct {
  ID  string `json:"id"`
  Settings map[string]any `json:"settings,intern"` // applies to keys of top-level map and all nested map[string]
}
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

No branches or pull requests

1 participant