Commit 20d56b71 by xiongziliang

性能优化

parent 71631a33
...@@ -250,7 +250,7 @@ static C get_http_header( const char *response_header[]){ ...@@ -250,7 +250,7 @@ static C get_http_header( const char *response_header[]){
auto value = response_header[i + 1]; auto value = response_header[i + 1];
if (key && value) { if (key && value) {
i += 2; i += 2;
header[key] = value; header.emplace(key,value);
continue; continue;
} }
break; break;
......
...@@ -88,7 +88,7 @@ static C get_http_header( const char *response_header[]){ ...@@ -88,7 +88,7 @@ static C get_http_header( const char *response_header[]){
auto value = response_header[i + 1]; auto value = response_header[i + 1];
if (key && value) { if (key && value) {
i += 2; i += 2;
header[key] = value; header.emplace(key,value);
continue; continue;
} }
break; break;
......
...@@ -28,27 +28,26 @@ class StrCaseMap : public multimap<string, string, StrCaseCompare>{ ...@@ -28,27 +28,26 @@ class StrCaseMap : public multimap<string, string, StrCaseCompare>{
StrCaseMap() = default; StrCaseMap() = default;
~StrCaseMap() = default; ~StrCaseMap() = default;
template <class K> string &operator[](const string &k){
string &operator[](K &&k){ auto it = find(k);
auto it = find(std::forward<K>(k));
if(it == end()){ if(it == end()){
it = Super::emplace(std::forward<K>(k),""); it = Super::emplace(k,"");
} }
return it->second; return it->second;
} }
template <class K,class V> template <typename V>
void emplace(K &&k , V &&v) { void emplace(const string &k, V &&v) {
auto it = find(std::forward<K>(k)); auto it = find(k);
if(it != end()){ if(it != end()){
return; return;
} }
Super::emplace(std::forward<K>(k),std::forward<V>(v)); Super::emplace(k,std::forward<V>(v));
} }
template <class K,class V> template <typename V>
void emplace_force(K &&k , V &&v) { void emplace_force(const string k , V &&v) {
Super::emplace(std::forward<K>(k),std::forward<V>(v)); Super::emplace(k,std::forward<V>(v));
} }
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论