Skip to content

Commit 1abc91c

Browse files
committed
LibRegex: Put debug mode code block behind a flag
This block should be optimized out anyway, but putting the whole thing behind a flag makes the intent clearer.
1 parent 4c491b8 commit 1abc91c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Libraries/LibRegex/RegexMatcher.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,19 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
178178
for (auto const& view : views)
179179
const_cast<RegexStringView&>(view).set_unicode(unicode);
180180

181-
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful)) {
182-
if (views.size() > 1 && input.start_offset > views.first().length()) {
183-
dbgln_if(REGEX_DEBUG, "Started with start={}, goff={}, skip={}", input.start_offset, input.global_offset, lines_to_skip);
184-
for (auto const& view : views) {
185-
if (input.start_offset < view.length() + 1)
186-
break;
187-
++lines_to_skip;
188-
input.start_offset -= view.length() + 1;
189-
input.global_offset += view.length() + 1;
181+
if constexpr (REGEX_DEBUG) {
182+
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful)) {
183+
if (views.size() > 1 && input.start_offset > views.first().length()) {
184+
dbgln("Started with start={}, goff={}, skip={}", input.start_offset, input.global_offset, lines_to_skip);
185+
for (auto const& view : views) {
186+
if (input.start_offset < view.length() + 1)
187+
break;
188+
++lines_to_skip;
189+
input.start_offset -= view.length() + 1;
190+
input.global_offset += view.length() + 1;
191+
}
192+
dbgln("Ended with start={}, goff={}, skip={}", input.start_offset, input.global_offset, lines_to_skip);
190193
}
191-
dbgln_if(REGEX_DEBUG, "Ended with start={}, goff={}, skip={}", input.start_offset, input.global_offset, lines_to_skip);
192194
}
193195
}
194196

0 commit comments

Comments
 (0)