Skip to content

Commit 151c2dd

Browse files
committed
YQL-20297: Make generated regexes more stable
commit_hash:b3270397329599800d4e7b1f92b8e0f18e94cfd6
1 parent 3149bc4 commit 151c2dd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

yql/essentials/sql/v1/lexer/regex/generic.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ namespace NSQLTranslationV1 {
139139
}));
140140

141141
Sort(patterns, [](const TRegexPattern& lhs, const TRegexPattern& rhs) {
142-
return lhs.Body.length() > rhs.Body.length();
142+
const auto lhs_length = lhs.Body.length();
143+
const auto rhs_length = rhs.Body.length();
144+
145+
// Note: do not compare After and Before here as they are equal.
146+
return std::tie(lhs_length, lhs.Body) > std::tie(rhs_length, rhs.Body);
143147
});
144148

145149
TStringBuilder body;

0 commit comments

Comments
 (0)