Skip to content

Commit

Permalink
perf(transformer): faster parsing JSX pragmas from comments (#6151)
Browse files Browse the repository at this point in the history
Parse JSX pragmas faster by:

1. Finding patterns with byte-by-byte iteration, with fast path for ASCII.
2. Checking for the `@jsx` prefix first before parsing the rest of the pragma.

These routines could be speeded up further by using unchecked slicing (unsafe code). But I've avoided that as the routines at present are quite complex, so hard to verify. The exception is `trim_end`, which is trivial to verify, so I have used unchecked slicing there.

The perf gain here is only ~0.5%, but we should split these routines out into a separate common crate and further optimize them, so that they can be used elsewhere in the codebase where we do string operations, which are often quite expensive.
  • Loading branch information
overlookmotel committed Sep 29, 2024
1 parent 646cd1d commit 40bd919
Show file tree
Hide file tree
Showing 3 changed files with 625 additions and 54 deletions.
Loading

0 comments on commit 40bd919

Please sign in to comment.