Skip to content

Commit f707996

Browse files
cmdcolinclaude
andcommitted
simplify parseInfo by merging duplicated decode loop
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 14e3a4a commit f707996

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

src/Variant.ts

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,30 +98,17 @@ export class Variant {
9898
const rawItems = val.split(',')
9999
const itemsLen = rawItems.length
100100

101-
if (hasDecode) {
102-
const items: (string | number | undefined)[] = []
103-
for (let j = 0; j < itemsLen; j++) {
104-
const v = rawItems[j] ?? ''
105-
if (v === '.') {
106-
items.push(undefined)
107-
} else {
108-
const decoded = decodeURIComponentNoThrow(v)
109-
items.push(isNumber ? Number(decoded) : decoded)
110-
}
111-
}
112-
result[key] = items
113-
} else {
114-
const items: (string | number | undefined)[] = []
115-
for (let j = 0; j < itemsLen; j++) {
116-
const v = rawItems[j] ?? ''
117-
if (v === '.') {
118-
items.push(undefined)
119-
} else {
120-
items.push(isNumber ? Number(v) : v)
121-
}
101+
const items: (string | number | undefined)[] = []
102+
for (let j = 0; j < itemsLen; j++) {
103+
const v = rawItems[j] ?? ''
104+
if (v === '.') {
105+
items.push(undefined)
106+
} else {
107+
const w = hasDecode ? decodeURIComponentNoThrow(v) : v
108+
items.push(isNumber ? Number(w) : w)
122109
}
123-
result[key] = items
124110
}
111+
result[key] = items
125112
}
126113
}
127114
return result

0 commit comments

Comments
 (0)