mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Micro-optimize argument retrieval
This commit is contained in:
@ -1095,13 +1095,15 @@ class basic_format_args {
|
|||||||
void set_data(const format_arg *args) { args_ = args; }
|
void set_data(const format_arg *args) { args_ = args; }
|
||||||
|
|
||||||
format_arg do_get(size_type index) const {
|
format_arg do_get(size_type index) const {
|
||||||
|
format_arg arg;
|
||||||
long long signed_types = static_cast<long long>(types_);
|
long long signed_types = static_cast<long long>(types_);
|
||||||
if (signed_types < 0) {
|
if (signed_types < 0) {
|
||||||
unsigned long long num_args =
|
unsigned long long num_args =
|
||||||
static_cast<unsigned long long>(-signed_types);
|
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)
|
if (index > internal::max_packed_args)
|
||||||
return arg;
|
return arg;
|
||||||
arg.type_ = type(index);
|
arg.type_ = type(index);
|
||||||
|
@ -1972,7 +1972,8 @@ FMT_CONSTEXPR Iterator parse_arg_id(Iterator it, IDHandler &&handler) {
|
|||||||
do {
|
do {
|
||||||
c = *++it;
|
c = *++it;
|
||||||
} while (is_name_start(c) || ('0' <= c && c <= '9'));
|
} 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;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user