From a8d6f309c8d69b499814aa5009d32c59e0ab8d4b Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 17 Jul 2017 06:26:22 -0700 Subject: [PATCH] Minor optimizations --- fmt/format.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fmt/format.h b/fmt/format.h index 24dcedf8..71b49e2c 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -2261,7 +2261,7 @@ class basic_writer { // Writes a formatted integer. template - void write_int(T value, Spec spec); + void write_int(T value, const Spec& spec); // Formats a floating-point number (double or long double). template @@ -2537,7 +2537,7 @@ typename basic_writer::CharPtr basic_writer::prepare_int_buffer( template template -void basic_writer::write_int(T value, Spec spec) { +void basic_writer::write_int(T value, const Spec& spec) { unsigned prefix_size = 0; typedef typename internal::int_traits::main_type UnsignedType; UnsignedType abs_value = static_cast(value); @@ -3227,10 +3227,11 @@ inline typename basic_context::format_arg template inline typename basic_context::format_arg basic_context::parse_arg_id() { + format_arg arg; const Char *&s = this->ptr(); if (!internal::is_name_start(*s)) { const char *error = 0; - format_arg arg = *s < '0' || *s > '9' ? + arg = *s < '0' || *s > '9' ? this->next_arg(error) : get_arg(internal::parse_nonnegative_int(s), error); if (error) { @@ -3245,7 +3246,7 @@ inline typename basic_context::format_arg c = *++s; } while (internal::is_name_start(c) || ('0' <= c && c <= '9')); const char *error = 0; - format_arg arg = get_arg(basic_string_view(start, s - start), error); + arg = get_arg(basic_string_view(start, s - start), error); if (error) FMT_THROW(format_error(error)); return arg; @@ -3253,7 +3254,7 @@ inline typename basic_context::format_arg // Formats a single argument. template -void do_format_arg(basic_buffer &buffer, basic_arg arg, +void do_format_arg(basic_buffer &buffer, const basic_arg& arg, Context &ctx) { const Char *&s = ctx.ptr(); basic_format_specs spec;