Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
21177757
Commit
21177757
authored
6 years ago
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Micro-optimize parsing
parent
be0e2684
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
15 deletions
+17
-15
include/fmt/format.h
include/fmt/format.h
+17
-15
No files found.
include/fmt/format.h
View file @
21177757
...
...
@@ -2102,21 +2102,21 @@ struct id_adapter {
Handler &handler;
};
template <bool IS_CONSTEXPR, class InputIt, class T>
FMT_CONSTEXPR InputIt find(InputIt first, InputIt last, const T &value) {
for (; first != last; ++first) {
if (*first == value)
return first;
// Return the result via the out param to workaround gcc bug 77539.
template <bool IS_CONSTEXPR, typename T, typename Ptr = const T*>
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out) {
for (out = first; out != last; ++out) {
if (*out == value)
return true;
}
return
last
;
return
false
;
}
template <>
inline const char *find<false, const char*, char>(
const char *first, const char *last, const char &value) {
auto result = static_cast<const char*>(
std::memchr(first, value, last - first));
return result ? result : last;
inline bool find<false, char>(
const char *first, const char *last, char value, const char *&out) {
out = static_cast<const char*>(std::memchr(first, value, last - first));
return out != FMT_NULL;
}
template <bool IS_CONSTEXPR, typename Char, typename Handler>
...
...
@@ -2125,8 +2125,8 @@ FMT_CONSTEXPR void parse_format_string(
struct writer {
FMT_CONSTEXPR void operator()(const Char *begin, const Char *end) {
for (;;) {
auto p = find<IS_CONSTEXPR>(begin, end, '}')
;
if (
p == end
) {
const Char *p = FMT_NULL
;
if (
!find<IS_CONSTEXPR>(begin, end, '}', p)
) {
handler_.on_text(begin, end);
return;
}
...
...
@@ -2146,8 +2146,8 @@ FMT_CONSTEXPR void parse_format_string(
for (;;) {
// Doing two passes with memchr (one for '{' and another for '}') is up to
// 2.5x faster than the naive one-pass implementation on long format strings.
auto p = find<IS_CONSTEXPR>(begin, end, '{')
;
if (
p == end
) {
const Char *p = FMT_NULL
;
if (
!find<IS_CONSTEXPR>(begin, end, '{', p)
) {
if (begin != end)
write(begin, end);
return;
...
...
@@ -2176,6 +2176,8 @@ FMT_CONSTEXPR void parse_format_string(
return;
}
begin = pointer_from(it) + 1;
if (begin == end)
return;
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment