mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-29 21:26:48 -06:00
Opening a workbook gave each clashing macro name a suffix by trying " (2)", " (3)"... in turn, and each try scanned every macro accepted so far. A file with 1,000 macros of the same 255-character name made about 300 million name comparisons. Load now keeps a set of the names in use (ASCII case-insensitive, as find compares them) and, for each shortened name and suffix width, the next suffix to try, so each suffix is looked up about once. The result is unchanged: the smallest free suffix, within the name length limit, and the renamed macro still passes the final checks. unique_name keeps its signature. A test opens, saves and reopens 1,000 same-name macros in JSON and xlsx and keeps them all, and another counts lookups instead of timing them.