Avoid revalidating the entire remaining UTF-8 source for every lexer character
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず front/lexer/src/cursor.rs の advance メソッドと peek メソッドを確認し、次に #392 で追加された既存の UTF-8 カーソルテストを読みます。カーソルのオフセットと診断列がどのように記録されるかを確認し、長い入力を対象とするテストを追加する前後に lexer のテストを実行します。完了条件は、UTF-8 の処理とスパンを正しく保ちながら、文字ごとの操作で残りのサフィックス全体を検証しなくなることです。時間のアサーションは設けずに、スケーリングの測定結果を記録してください。
索引モデルが issue の本文から書いたものです。
説明
Problem
Lexer already stores its input as &str, but advance and peek repeatedly call std::str::from_utf8 on the entire remaining suffix. A long comment performs this linear suffix validation for each character, giving quadratic scanning work even though only the next character is needed.
Starting points: front/lexer/src/cursor.rs:25 and front/lexer/src/cursor.rs:47. Preserve the UTF-8 byte-offset and diagnostic-column contract; this is a cursor hot-path fix, not a lexer redesign. #392 added UTF-8 correctness tests but does not cover repeated suffix validation.
Reproduction
Audited canonical master d59bdab376bdc04edacdc8029b256cb8d55b5adf on Linux amd64 with a checkout-built Wave 0.0.1-alpha-dev, Rust 1.89.0 and LLVM 21.1.8.
With the debug compiler, checked files containing /* + N ASCII a characters + */\nfun main() {}\n, three executions per size:
| Comment bytes | Elapsed seconds |
|---|---|
| 30,000 | 0.0707, 0.0633, 0.0665 |
| 60,000 | 0.2024, 0.2087, 0.1956 |
| 120,000 | 0.7333, 0.7140, 0.7221 |
All checks succeed. Doubling the long comment approaches four times the scanning cost. These are debug-build observations, not release benchmark claims. The repeated full-suffix validation is also directly visible in the source.
Reproduce with target/debug/wavec check long-comment.wave; use time.perf_counter() around repeated subprocess invocations and keep the number of tokens constant.
Scope
Decode/look ahead within the already-valid string without scanning its full suffix again. Difficulty: easy; the existing UTF-8 cursor tests provide a starting point.
Completion criteria
- Preserve multibyte identifiers, comments, strings, CR/LF tracking and diagnostic spans.
- Remove full-suffix UTF-8 validation from per-character cursor operations.
- Add focused long-input correctness coverage and record scaling measurements; avoid a flaky wall-clock assertion in unit tests.
- 主要言語
- Rust
- スター
- 56
- フォーク
- 21
- 平均マージ
- 4時間 58分
- マージ済み PR(30日)
- 54
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
wavefnd/Wave のほかの issue
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue needs testing
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Distinguish Rust character literals from lifetimes in the spacing helper対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
good first issue gpu serve
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
documentation E-easy good first issue help wanted
難易度 1/5 1〜3時間 初心者へのやさしさ 91/100
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
charles-hood/DiagramCraft#73 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
ontologyportal/sigma-rs#200 ·
メンテナーはふだん 1 日以内に返信