Skip to content

Commit

Permalink
perf: improve deserialization
Browse files Browse the repository at this point in the history
Made it 2-2.5x faster.
  • Loading branch information
norskeld committed Jul 29, 2023
1 parent 2f21afe commit e138aa9
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,7 @@ export class Deserializer {
}

private readString(length: number): string {
const bytes = this.reader.range(length)

for (const byte of bytes) {
if (byte > 127) {
return decodeUtf8(bytes)
}
}

return String.fromCharCode(...bytes)
return decodeUtf8(this.reader.range(length))
}

private readArray(length: number): unknown[] {
Expand Down

0 comments on commit e138aa9

Please sign in to comment.