Skip to content

Commit da6765d

Browse files
perf(ksuid): update .parse()
- avoid allocation
1 parent 6960ebd commit da6765d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/ksuid/src/ksuid32.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class KSUID32 extends AKSUID {
2323
}
2424

2525
parse(id: string) {
26-
const buf = new Uint8Array(this.size);
26+
const buf = this.tmp;
2727
this.base.decodeBytes(id, buf);
2828
return {
2929
epoch: this.u32(buf) * 1000 + this.epoch,

packages/ksuid/src/ksuid64.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class KSUID64 extends AKSUID {
2727
}
2828

2929
parse(id: string) {
30-
const buf = new Uint8Array(this.size);
30+
const buf = this.tmp;
3131
this.base.decodeBytes(id, buf);
3232
return {
3333
epoch:

0 commit comments

Comments
 (0)