Skip to content

Commit

Permalink
Presuming the match on a character is more eficient than the indexOf …
Browse files Browse the repository at this point in the history
…here
  • Loading branch information
eoghanmurray committed Dec 18, 2024
1 parent 76e33d3 commit 339ecdb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/rrweb-snapshot/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,11 @@ export function splitCssText(
let j = 3;
for (; j < textContentNorm.length; j++) {
if (
// keep consuming css identifiers (to get a decent chunk more quickly)
textContentNorm[j].match(/[a-zA-Z0-9]/) ||
// substring needs to be unique to this section
textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1
) {
// substring needs to be unique to this section
continue;
}
break;
Expand Down

0 comments on commit 339ecdb

Please sign in to comment.