[colorer/Colorer-library] cregexp_refactoring: Use the first-character filter while searching so positionMoves skips impossible offsets. (bda1352)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Aug 16, 2026, 3:31:26 PM (12 hours ago) Aug 16
to farco...@googlegroups.com
Repository : https://github.com/colorer/Colorer-library
On branch : cregexp_refactoring
Link : https://github.com/colorer/Colorer-library/commit/bda13525dced1c19c7d2a9c1454f5103d0b5f3d8

>---------------------------------------------------------------

commit bda13525dced1c19c7d2a9c1454f5103d0b5f3d8
Author: Aleksey Dobrunov <cta...@ctapmex.com>
Date: Mon Aug 17 00:21:18 2026 +0500

Use the first-character filter while searching so positionMoves skips impossible offsets.


>---------------------------------------------------------------

bda13525dced1c19c7d2a9c1454f5103d0b5f3d8
src/colorer/cregexp/cregexp.cpp | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/src/colorer/cregexp/cregexp.cpp b/src/colorer/cregexp/cregexp.cpp
index 4ad5b48..0b08be9 100644
--- a/src/colorer/cregexp/cregexp.cpp
+++ b/src/colorer/cregexp/cregexp.cpp
@@ -1490,6 +1490,25 @@ inline bool CRegExp::parseRE(int pos)
matches->cMatch = cMatch;
matches->cnMatch = cnMatch;
do {
+ if (positionMoves) {
+ bool skip = false;
+ if (firstCharMaskUseful) {
+ if (toParse >= end) {
+ skip = true;
+ }
+ else {
+ const auto ch = static_cast<uint32_t>((*global_pattern)[toParse]);
+ if (ch < 128 && !(firstCharMask[ch >> 6] & (uint64_t(1) << (ch & 63))))
+ skip = true;
+ }
+ }
+ if (!skip && firstNode && !quickCheck(toParse))
+ skip = true;
+ if (skip) {
+ toParse = ++pos;
+ continue;
+ }
+ }
if (lowParse(tree_root, nullptr, toParse)) {
matches->topseSanitize(cMatch - 1);
matches->topnseSanitize(cnMatch - 1);


Reply all
Reply to author
Forward
0 new messages