deps: vendor regress 字节字面量优化 gate 改逐编译运行时标志 + 惰性物化单元向 IR——utf16 feature 编译期全局 gate 原会关掉全部 regex 的字节 pass 与执行器起始谓词快路径,启用即劣化全部 str 路径;现字节 pass 由 byte_literals 编译参数控制(str IR 传 true 与旧行为逐位一致、单元 IR 传 false),执行器起始谓词分派按输入编码切换(字节输入保留锚定/字节定位快路径、单元输入逐位尝试),单元向 IR 首次 find_from_utf16/find_from_ucs2 时重解析编译并缓存(正则留存源码码点序列),no_opt 标志同路径贯穿;fork 增量边界 = optimizer.rs 两处 cfg 改运行时标志(optimize 降为包装)+ api.rs Regex 两字段与 utf16 两入口改走单元产物 + classicalbacktrack.rs 两处 cfg 去除分派运行时化 + manifest 独立 [workspace] 表与 feature 注释刷新,其余与上游 0.11.1 逐位一致;新增回归钉五则(well-formed 匹配逐一相等/孤立 surrogate 属性命中/代理对 ≡ str 路径/字节指令与起始谓词按 IR 门控/no_opt 贯穿)

This commit is contained in:
2026-09-13 17:56:09 +00:00
parent f088858cf4
commit 2eea4f1fbc
4 changed files with 320 additions and 39 deletions
+25 -26
View File
@@ -7,7 +7,6 @@ use crate::cursor::{Backward, Direction, Forward};
use crate::exec;
use crate::indexing;
use crate::indexing::{AsciiInput, ElementType, InputIndexer, Utf8Input};
#[cfg(not(feature = "utf16"))]
use crate::insn::StartPredicate;
use crate::insn::{CompiledRegex, Insn, LoopFields};
use crate::matchers;
@@ -1053,7 +1052,6 @@ impl<Input: InputIndexer> BacktrackExecutor<'_, Input> {
/// \return the next match for an anchored regex that only matches at the start.
/// This avoids any string searching and only tries matching at the given position.
#[cfg(not(feature = "utf16"))]
fn next_match_anchored(
&mut self,
pos: Input::Position,
@@ -1118,31 +1116,32 @@ impl<Input: InputIndexer> exec::MatchProducer for BacktrackExecutor<'_, Input> {
pos: Input::Position,
next_start: &mut Option<Input::Position>,
) -> Option<Match> {
// When UTF-16 support is active prefix search is not used due to the different encoding.
#[cfg(feature = "utf16")]
return self.next_match_with_prefix_search(pos, next_start, &bytesearch::EmptyString {});
#[cfg(not(feature = "utf16"))]
match &self.matcher.re.start_pred {
StartPredicate::Arbitrary => {
self.next_match_with_prefix_search(pos, next_start, &bytesearch::EmptyString {})
}
StartPredicate::StartAnchored => self.next_match_anchored(pos, next_start),
StartPredicate::ByteSet1(bytes) => {
self.next_match_with_prefix_search(pos, next_start, bytes)
}
StartPredicate::ByteSet2(bytes) => {
self.next_match_with_prefix_search(pos, next_start, bytes)
}
StartPredicate::ByteSet3(bytes) => {
self.next_match_with_prefix_search(pos, next_start, bytes)
}
StartPredicate::ByteSeq(bytes) => {
self.next_match_with_prefix_search(pos, next_start, bytes.as_ref())
}
StartPredicate::ByteBracket(bitmap) => {
self.next_match_with_prefix_search(pos, next_start, bitmap)
// 字节输入(UTF-8/ASCII)按起始谓词走定位快路径;
// 单元输入(UTF-16/UCS-2)无法字节级前缀搜索,逐位尝试匹配。
if Input::CODE_UNITS_ARE_BYTES {
match &self.matcher.re.start_pred {
StartPredicate::Arbitrary => {
self.next_match_with_prefix_search(pos, next_start, &bytesearch::EmptyString {})
}
StartPredicate::StartAnchored => self.next_match_anchored(pos, next_start),
StartPredicate::ByteSet1(bytes) => {
self.next_match_with_prefix_search(pos, next_start, bytes)
}
StartPredicate::ByteSet2(bytes) => {
self.next_match_with_prefix_search(pos, next_start, bytes)
}
StartPredicate::ByteSet3(bytes) => {
self.next_match_with_prefix_search(pos, next_start, bytes)
}
StartPredicate::ByteSeq(bytes) => {
self.next_match_with_prefix_search(pos, next_start, bytes.as_ref())
}
StartPredicate::ByteBracket(bitmap) => {
self.next_match_with_prefix_search(pos, next_start, bitmap)
}
}
} else {
self.next_match_with_prefix_search(pos, next_start, &bytesearch::EmptyString {})
}
}
}