Skip to content

Performance: fast-scan delimiter candidates in template and cloze tokenizers #5345

Description

@pierspad

Motivation

In rslib/src/template.rs (TemplateMode::next_token) and rslib/src/cloze.rs (cloze::normal_text), tokenizers iterate character-by-character and execute nom parser combinators on every character. For templates and cloze notes containing substantial HTML/CSS, this causes thousands of redundant failed parser combinator executions.

Proposed change

Fast-forward through non-delimiter slices by scanning for candidate ASCII delimiter bytes ({, <, }) using str::find before invoking the nom parsers, avoiding unnecessary parser overhead on plain text and HTML chunks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions