diff options
author | vitya-smirnov <[email protected]> | 2025-09-05 18:16:17 +0300 |
---|---|---|
committer | vitya-smirnov <[email protected]> | 2025-09-05 18:38:24 +0300 |
commit | 151c2dd705e3c0e3d33d9e62c138072823a9bf7e (patch) | |
tree | af36c21222832c15f5d19acfb94b63cb1f3367e9 | |
parent | 3149bc4905e8b3ce046f253414e91392779f31d9 (diff) |
YQL-20297: Make generated regexes more stable
commit_hash:b3270397329599800d4e7b1f92b8e0f18e94cfd6
-rw-r--r-- | yql/essentials/sql/v1/lexer/regex/generic.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/yql/essentials/sql/v1/lexer/regex/generic.cpp b/yql/essentials/sql/v1/lexer/regex/generic.cpp index 3603a31f690..50b2d78cf77 100644 --- a/yql/essentials/sql/v1/lexer/regex/generic.cpp +++ b/yql/essentials/sql/v1/lexer/regex/generic.cpp @@ -139,7 +139,11 @@ namespace NSQLTranslationV1 { })); Sort(patterns, [](const TRegexPattern& lhs, const TRegexPattern& rhs) { - return lhs.Body.length() > rhs.Body.length(); + const auto lhs_length = lhs.Body.length(); + const auto rhs_length = rhs.Body.length(); + + // Note: do not compare After and Before here as they are equal. + return std::tie(lhs_length, lhs.Body) > std::tie(rhs_length, rhs.Body); }); TStringBuilder body; |