Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Avoid revalidating the entire remaining UTF-8 source for every lexer character

已关闭 适合新手
#935 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

已经有一个关联 PR 被合并了。

  • #965 来自 @hiyouwhatsapp —— 已合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
83/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
compilers

调研方向

从 front/lexer/src/cursor.rs 中的 advance 和 peek 方法开始,然后阅读为 #392 添加的现有 UTF-8 游标测试。检查游标偏移量和诊断列的跟踪方式,并在添加针对长输入的测试覆盖前后运行 lexer 测试。完成标准是:逐字符操作不再验证整个剩余后缀,同时 UTF-8 处理和 spans 仍然正确;记录扩展性测量结果,不添加时间断言。

由索引模型根据 Issue 内容生成。

描述

good first issue performance

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
平均合并
5 小时 2 分钟
30 天内合并 PR
56

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wavefnd/Wave 的其他 Issue

查看 wavefnd/Wave 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。