From 8615ff2accbf1f291b1dcf9665b34ac6121013f4 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 15 Jul 2018 06:29:51 -0700 Subject: [PATCH] Micro-optimize argument retrieval --- include/fmt/core.h | 6 ++++-- include/fmt/format.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 739d6dee..19063bc5 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -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(types_); if (signed_types < 0) { unsigned long long num_args = static_cast(-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); diff --git a/include/fmt/format.h b/include/fmt/format.h index 11002e4c..eb0db49c 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -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(pointer_from(start), to_unsigned(it - start))); + handler(basic_string_view( + pointer_from(start), to_unsigned(it - start))); return it; }