Skip to content

Commit

Permalink
Micro-optimize argument retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jul 15, 2018
1 parent 916ed99 commit 8615ff2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1095,13 +1095,15 @@ class basic_format_args {
void set_data(const format_arg *args) { args_ = args; }

format_arg do_get(size_type index) const {
format_arg arg;
long long signed_types = static_cast<long long>(types_);
if (signed_types < 0) {
unsigned long long num_args =
static_cast<unsigned long long>(-signed_types);
return index < num_args ? args_[index] : format_arg();
if (index < num_args)
arg = args_[index];
return arg;;
}
format_arg arg;
if (index > internal::max_packed_args)
return arg;
arg.type_ = type(index);
Expand Down
3 changes: 2 additions & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,8 @@ FMT_CONSTEXPR Iterator parse_arg_id(Iterator it, IDHandler &&handler) {
do {
c = *++it;
} while (is_name_start(c) || ('0' <= c && c <= '9'));
handler(basic_string_view<char_type>(pointer_from(start), to_unsigned(it - start)));
handler(basic_string_view<char_type>(
pointer_from(start), to_unsigned(it - start)));
return it;
}

Expand Down

0 comments on commit 8615ff2

Please sign in to comment.