Skip to content

Commit b1c1571

Browse files
lfportalclaude
andcommitted
Remove dead counting loop in GenerateAssetMappings
The first pass of _countJsonArrayElements increments depth on every '{' or '[', so the subsequent 'else if (c == "{" && depth == 1)' branch is unreachable and count is always 0. The second pass (with depth tracking only for '['/']') is what actually produces the count. Drop the dead first loop. imx_tokens.json entries are flat, so the remaining logic correctly counts top-level array objects. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 159f77e commit b1c1571

1 file changed

Lines changed: 0 additions & 23 deletions

File tree

script/GenerateAssetMappings.s.sol

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,29 +111,6 @@ contract GenerateAssetMappings is Script {
111111
uint256 depth = 0;
112112
bool inString = false;
113113

114-
for (uint256 i = 0; i < jsonBytes.length; i++) {
115-
bytes1 c = jsonBytes[i];
116-
117-
if (c == '"' && (i == 0 || jsonBytes[i - 1] != "\\")) {
118-
inString = !inString;
119-
}
120-
121-
if (!inString) {
122-
if (c == "[" || c == "{") {
123-
depth++;
124-
} else if (c == "]" || c == "}") {
125-
depth--;
126-
} else if (c == "{" && depth == 1) {
127-
// We're at the start of a top-level object in the array
128-
count++;
129-
}
130-
}
131-
}
132-
133-
// Re-count by looking for opening braces at depth 1
134-
count = 0;
135-
depth = 0;
136-
inString = false;
137114
for (uint256 i = 0; i < jsonBytes.length; i++) {
138115
bytes1 c = jsonBytes[i];
139116

0 commit comments

Comments
 (0)