Skip to content

Fix repeated names from the name compressor - #1489

Merged
Frotty merged 1 commit into
masterfrom
fix-name-generator-collisions
Oct 17, 2026
Merged

Frotty merged 1 commit into
masterfrom
fix-name-generator-collisions

Conversation

@Frotty

@Frotty Frotty commented Oct 17, 2026

Copy link
Copy Markdown
Member

NameGenerator.getToken picked the alphabet per digit (with _ once the remaining id exceeded 63) but always divided by the length of the alphabet without it. Distinct ids therefore mapped to the same token: www came out as token 3162 and again as 3213, and the first 200000 tokens held 3111 repeats.

ImCompressor (-opt) draws globals, functions and locals from this one stream. The Jass and Lua backends rename each clash with a suffix, so the script stayed valid, but a map with more than about 3200 compressed names got names such as www_1 and sww_1 instead of fresh short ones.

The fix uses one alphabet for every position after the first. The first 3213 tokens are unchanged.

Tests (OptimizerTests), both red before the fix:

  • compressedNamesAreUnique: 200000 tokens from getUniqueToken are all distinct.
  • compressionGivesThousandsOfGlobalsDistinctNames: 3300 globals compiled with -opt keep their generated names; the backend renames none of them.

The generator still produces no reserved word that RestrictedCompressedNames misses within the first 200000 tokens.

NameGenerator picked the alphabet per digit (with an underscore once the
remaining id exceeded 63) but always divided by the length of the alphabet
without it, so distinct ids mapped to the same token: www came out as token
3162 and again as 3213, and the first 200000 tokens held 3111 repeats.
The compressor draws globals, functions and locals from this one stream,
and the backends renamed each clash with a suffix such as _1, so a map with
more than about 3200 compressed names got longer names than necessary.

Use one alphabet for every position after the first.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T17:41:22.440553Z 2f0a25f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Frotty
Frotty merged commit 2de9817 into master Oct 17, 2026
2 checks passed
@Frotty
Frotty deleted the fix-name-generator-collisions branch November 25, 2026 08:54
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