From fbc38b90838bb67c5bd298866e0497dbb797a6d5 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 31 Aug 2018 14:42:45 -0700 Subject: [PATCH] Pass heavy arguments by ref --- include/fmt/core.h | 2 +- include/fmt/format.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index e55c3a02..e705b93f 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -720,7 +720,7 @@ class basic_format_arg { template friend FMT_CONSTEXPR typename internal::result_of::type - visit(Visitor &&vis, basic_format_arg arg); + visit(Visitor &&vis, const basic_format_arg &arg); friend class basic_format_args; friend class internal::arg_map; diff --git a/include/fmt/format.h b/include/fmt/format.h index b79a889f..65101326 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1165,7 +1165,7 @@ struct monostate {}; */ template FMT_CONSTEXPR typename internal::result_of::type - visit(Visitor &&vis, basic_format_arg arg) { + visit(Visitor &&vis, const basic_format_arg &arg) { typedef typename Context::char_type char_type; switch (arg.type_) { case internal::none_type: @@ -2405,7 +2405,7 @@ class basic_writer { // // where is written by f(it). template - void write_padded(std::size_t size, const align_spec &spec, F f); + void write_padded(std::size_t size, const align_spec &spec, F &&f); template struct padded_int_writer { @@ -2755,7 +2755,7 @@ class basic_writer { template template void basic_writer::write_padded( - std::size_t size, const align_spec &spec, F f) { + std::size_t size, const align_spec &spec, F &&f) { unsigned width = spec.width(); if (width <= size) return f(reserve(size)); @@ -3250,7 +3250,8 @@ class dynamic_formatter { template typename basic_format_context::format_arg - basic_format_context::get_arg(basic_string_view name) { + basic_format_context::get_arg( + basic_string_view name) { map_.init(this->args()); format_arg arg = map_.find(name); if (arg.type() == internal::none_type)