Skip to content

Commit 08ba069

Browse files
authored
perf(v4): read Luhn digits with charCodeAt instead of string indexing (#6529)
1 parent 1ec6b7c commit 08ba069

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎packages/zod/src/v4/core/schemas.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ function isLuhnAlgo(digits: string): boolean {
11111111
let bit = 1;
11121112
let sum = 0;
11131113
while (length) {
1114-
const value = +digits[--length]!;
1114+
const value = digits.charCodeAt(--length) - 48;
11151115
bit ^= 1;
11161116
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value]! : value;
11171117
}

0 commit comments

Comments
 (0)