🟡 [M21] get_file_info 与 count_existing_lines 对无尾换行文件计数不一致 #40
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
get_file_info使用read_until(b'\n')手动计数;无尾换行的最后一行可能与count_existing_lines的reader.lines().count()行为不一致。影响
同一文件在不同函数中得到不同
line_count,会影响avg_line_length和 benchmark 文件信息。位置
crates/bench/src/data_gen.rs:25crates/bench/src/data_gen.rs:117建议
统一行计数实现,例如都使用
reader.lines().count(),或显式处理最后一段无换行内容。经审核,原 issue 描述的不一致实际不存在:read_until(b'\n') 和 lines().count() 对无尾换行文件的行为一致,均会计入最后一行。
但为减少重复代码和维护风险,已将 get_file_info 中的手动 read_until 循环替换为复用已有的 count_existing_lines(),统一行计数实现。
commit:
5656b26