Skip to content

Commit

Permalink
chore: drop useless fast exit
Browse files Browse the repository at this point in the history
  • Loading branch information
seia-soto committed Dec 12, 2024
1 parent 0339bdc commit 3270e6a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/adblocker/src/data-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,8 @@ export function sizeOfASCII(str: string): number {
* Return number of bytes needed to serialize `str` UTF8 string.
*/
export function sizeOfUTF8(str: string): number {
// Fast path for short strs considering the worst case (output ratio of 3)
if (str.length < 43 /* Math.ceil(127 / 3) */) {
return 1 + TEXT_ENCODER.encode(str).length;
}
const result = TEXT_ENCODER.encode(str);
return sizeOfLength(result.length) + result.length;
const encoded = TEXT_ENCODER.encode(str);
return sizeOfLength(encoded.length) + encoded.length;
}

/**
Expand Down

0 comments on commit 3270e6a

Please sign in to comment.