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

Deduplicate locale tokens #399

Merged
merged 1 commit into from
Feb 19, 2022
Merged

Conversation

casperisfine
Copy link

   5.02 kB      57  "%<locale>s.dry_schema.rules.%<name>s"
                57  dry-schema-1.8.0/lib/dry/schema/messages/yaml.rb:43

   5.02 kB      57  "%<locale>s.dry_schema.errors"
                57  dry-schema-1.8.0/lib/dry/schema/messages/yaml.rb:41

```
   5.02 kB      57  "%<locale>s.dry_schema.rules.%<name>s"
                57  dry-schema-1.8.0/lib/dry/schema/messages/yaml.rb:43

   5.02 kB      57  "%<locale>s.dry_schema.errors"
                57  dry-schema-1.8.0/lib/dry/schema/messages/yaml.rb:41
```
@solnic
Copy link
Member

solnic commented Feb 18, 2022

Thanks, could you tell me what this is actually doing though?

@casperisfine
Copy link
Author

String#-@ interns the string.

As shown heap-profiler, if you instantiate X schemas, you end up with X copies of these two strings.

By using String#-@ we deduplicate these strings so that all schemas point to the same (frozen) one, saving about 10KiB (in this case).

@solnic solnic merged commit 2bdc1a3 into dry-rb:master Feb 19, 2022
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.

None yet

3 participants