Skip to content

Deduplicate locale tokens - #399

Merged
solnic merged 1 commit into
dry-rb:masterfrom
casperisfine:intern-locale-keys
Feb 19, 2022
Merged

Deduplicate locale tokens#399
solnic merged 1 commit into
dry-rb:masterfrom
casperisfine:intern-locale-keys

Conversation

@casperisfine

Copy link
Copy Markdown
   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
```
@casperisfine
casperisfine requested a review from solnic as a code owner February 17, 2022 08:57
@solnic

solnic commented Feb 18, 2022

Copy link
Copy Markdown
Member

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

@casperisfine

Copy link
Copy Markdown
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.

3 participants