From 20d56b713f63cd284456f49b0ac57c65c885a095 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 28 Dec 2019 13:39:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/source/mk_events_objects.cpp | 2 +- api/source/mk_httpclient.cpp | 2 +- src/Common/Parser.h | 21 ++++++++++----------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/api/source/mk_events_objects.cpp b/api/source/mk_events_objects.cpp index 69e9fa3a..f959668a 100644 --- a/api/source/mk_events_objects.cpp +++ b/api/source/mk_events_objects.cpp @@ -250,7 +250,7 @@ static C get_http_header( const char *response_header[]){ auto value = response_header[i + 1]; if (key && value) { i += 2; - header[key] = value; + header.emplace(key,value); continue; } break; diff --git a/api/source/mk_httpclient.cpp b/api/source/mk_httpclient.cpp index 0e32b472..e1262011 100755 --- a/api/source/mk_httpclient.cpp +++ b/api/source/mk_httpclient.cpp @@ -88,7 +88,7 @@ static C get_http_header( const char *response_header[]){ auto value = response_header[i + 1]; if (key && value) { i += 2; - header[key] = value; + header.emplace(key,value); continue; } break; diff --git a/src/Common/Parser.h b/src/Common/Parser.h index eaa1874d..bd15d0b8 100644 --- a/src/Common/Parser.h +++ b/src/Common/Parser.h @@ -28,27 +28,26 @@ class StrCaseMap : public multimap{ StrCaseMap() = default; ~StrCaseMap() = default; - template - string &operator[](K &&k){ - auto it = find(std::forward(k)); + string &operator[](const string &k){ + auto it = find(k); if(it == end()){ - it = Super::emplace(std::forward(k),""); + it = Super::emplace(k,""); } return it->second; } - template - void emplace(K &&k , V &&v) { - auto it = find(std::forward(k)); + template + void emplace(const string &k, V &&v) { + auto it = find(k); if(it != end()){ return; } - Super::emplace(std::forward(k),std::forward(v)); + Super::emplace(k,std::forward(v)); } - template - void emplace_force(K &&k , V &&v) { - Super::emplace(std::forward(k),std::forward(v)); + template + void emplace_force(const string k , V &&v) { + Super::emplace(k,std::forward(v)); } };