From 27da08ee68168eb9b548947881f6eace969c3331 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 14 Jul 2015 22:43:02 +0900 Subject: [PATCH] nghttpx: Add inline LogFragment ctor --- src/shrpx_config.cc | 18 ++++-------------- src/shrpx_log.h | 2 ++ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index cb255cf3..37b9693b 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -323,13 +323,6 @@ int parse_int(T *dest, const char *opt, const char *optarg) { return 0; } -namespace { -LogFragment make_log_fragment(LogFragmentType type, - std::unique_ptr value = nullptr) { - return LogFragment{type, std::move(value)}; -} -} // namespace - namespace { bool var_token(char c) { return util::isAlpha(c) || util::isDigit(c) || c == '_'; @@ -418,19 +411,17 @@ std::vector parse_log_format(const char *optarg) { } if (literal_start < var_start) { - res.push_back(make_log_fragment(SHRPX_LOGF_LITERAL, - strcopy(literal_start, var_start))); + res.emplace_back(SHRPX_LOGF_LITERAL, strcopy(literal_start, var_start)); } literal_start = p; if (value == nullptr) { - res.push_back(make_log_fragment(type)); + res.emplace_back(type); continue; } - res.push_back( - make_log_fragment(type, strcopy(value, var_name + var_namelen))); + res.emplace_back(type, strcopy(value, var_name + var_namelen)); auto &v = res.back().value; for (size_t i = 0; v[i]; ++i) { if (v[i] == '_') { @@ -440,8 +431,7 @@ std::vector parse_log_format(const char *optarg) { } if (literal_start != eop) { - res.push_back( - make_log_fragment(SHRPX_LOGF_LITERAL, strcopy(literal_start, eop))); + res.emplace_back(SHRPX_LOGF_LITERAL, strcopy(literal_start, eop)); } return res; diff --git a/src/shrpx_log.h b/src/shrpx_log.h index 1d63e641..e13be41e 100644 --- a/src/shrpx_log.h +++ b/src/shrpx_log.h @@ -123,6 +123,8 @@ enum LogFragmentType { }; struct LogFragment { + LogFragment(LogFragmentType type, std::unique_ptr value = nullptr) + : type(type), value(std::move(value)) {} LogFragmentType type; std::unique_ptr value; };