Commit aeb6add3 authored by Victor Zverovich's avatar Victor Zverovich

Skip strchr for the common case

parent 5614289d
...@@ -2139,11 +2139,11 @@ FMT_CONSTEXPR void parse_format_string( ...@@ -2139,11 +2139,11 @@ FMT_CONSTEXPR void parse_format_string(
Handler &handler_; Handler &handler_;
} write{handler}; } write{handler};
auto begin = format_str.data(), end = begin + format_str.size(); auto begin = format_str.data(), end = begin + format_str.size();
for (;;) { while (begin != end) {
// Doing two passes with memchr (one for '{' and another for '}') is up to // Doing two passes with memchr (one for '{' and another for '}') is up to
// 2.5x faster than the naive one-pass implementation on big format strings. // 2.5x faster than the naive one-pass implementation on big format strings.
const Char *p = FMT_NULL; const Char *p = begin;
if (!find<IS_CONSTEXPR>(begin, end, '{', p)) if (*begin != '{' && !find<IS_CONSTEXPR>(begin, end, '{', p))
return write(begin, end); return write(begin, end);
write(begin, p); write(begin, p);
++p; ++p;
...@@ -2165,7 +2165,6 @@ FMT_CONSTEXPR void parse_format_string( ...@@ -2165,7 +2165,6 @@ FMT_CONSTEXPR void parse_format_string(
return handler.on_error("missing '}' in format string"); return handler.on_error("missing '}' in format string");
} }
begin = pointer_from(it) + 1; begin = pointer_from(it) + 1;
if (begin == end) return;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment