Skip to content

UTF16 variants #9

Description

@guybedford

es-module-lexer does lexing on UTF16 to easily provide offsets directly against the original JS string value.

One of the major bottlenecks for this project is the UTF16 copy itself.

From the es-module-lexer benchmarks, copy time is roughtly 1/4 of the total lexing time. Using NodeJS's Buffer.from(s,'utf16le') improves the copy time by 13x, overall providing roughtly a 23% performance improvement for end to end lexing.

The analog here would be supporting encodeStringIntoUTF16Memory and encodeStringIntoUTF16Array with well-formed replacements for lone surrogates.

Since these benchmarks clearly prove the benefit, I can provide a PR if there is further interest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions