Optimize performance

This commit is contained in:
Tindy X committed 2020-07-05 02:39:00 +08:00
1 parent c2564a6fd9
commit 6cb369fa34
8 files changed
+62 -62

No files matched your search

+1 -1
View File
@@ -265,7 +265,7 @@ public:
read_sections.push_back(curSection); //add to read sections list read_sections.push_back(curSection); //add to read sections list
ini_content.emplace(curSection, itemGroup); //insert previous section to content map ini_content.emplace(curSection, itemGroup); //insert previous section to content map
if(std::count(section_order.cbegin(), section_order.cend(), curSection) == 0) if(std::count(section_order.cbegin(), section_order.cend(), curSection) == 0)
section_order.emplace_back(curSection); section_order.emplace_back(std::move(curSection));
} }
eraseElements(itemGroup); //reset section storage eraseElements(itemGroup); //reset section storage
+17 -15
View File
@@ -358,7 +358,7 @@ int importItems(string_array &target, bool scope_limit = true)
strLine.erase(--lineSize); strLine.erase(--lineSize);
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
continue; continue;
result.emplace_back(strLine); result.emplace_back(std::move(strLine));
itemCount++; itemCount++;
} }
ss.clear(); ss.clear();
@@ -394,7 +394,7 @@ void readRegexMatch(YAML::Node node, const std::string &delimiter, string_array
strLine = match + delimiter + rep; strLine = match + delimiter + rep;
else else
continue; continue;
dest.emplace_back(strLine); dest.emplace_back(std::move(strLine));
} }
importItems(dest, scope_limit); importItems(dest, scope_limit);
} }
@@ -426,7 +426,7 @@ void readEmoji(YAML::Node node, string_array &dest, bool scope_limit = true)
strLine = match + "," + rep; strLine = match + "," + rep;
else else
continue; continue;
dest.emplace_back(strLine); dest.emplace_back(std::move(strLine));
} }
importItems(dest, scope_limit); importItems(dest, scope_limit);
} }
@@ -451,7 +451,7 @@ void readGroup(YAML::Node node, string_array &dest, bool scope_limit = true)
std::string url = "http://www.gstatic.com/generate_204", interval = "300", tolerance, timeout; std::string url = "http://www.gstatic.com/generate_204", interval = "300", tolerance, timeout;
object["name"] >>= name; object["name"] >>= name;
object["type"] >>= type; object["type"] >>= type;
tempArray.emplace_back(name); tempArray.emplace_back(std::move(name));
tempArray.emplace_back(type); tempArray.emplace_back(type);
object["url"] >>= url; object["url"] >>= url;
object["interval"] >>= interval; object["interval"] >>= interval;
@@ -472,7 +472,7 @@ void readGroup(YAML::Node node, string_array &dest, bool scope_limit = true)
default: default:
if(tempArray.size() < 3) if(tempArray.size() < 3)
continue; continue;
tempArray.emplace_back(url); tempArray.emplace_back(std::move(url));
tempArray.emplace_back(interval + "," + timeout + "," + tolerance); tempArray.emplace_back(interval + "," + timeout + "," + tolerance);
} }
@@ -480,7 +480,7 @@ void readGroup(YAML::Node node, string_array &dest, bool scope_limit = true)
{ {
return std::move(a) + "`" + std::move(b); return std::move(a) + "`" + std::move(b);
}); });
dest.emplace_back(strLine); dest.emplace_back(std::move(strLine));
} }
importItems(dest, scope_limit); importItems(dest, scope_limit);
} }
@@ -508,7 +508,7 @@ void readRuleset(YAML::Node node, string_array &dest, bool scope_limit = true)
strLine = group + ",[]" + name; strLine = group + ",[]" + name;
else else
continue; continue;
dest.emplace_back(strLine); dest.emplace_back(std::move(strLine));
} }
importItems(dest, scope_limit); importItems(dest, scope_limit);
} }
@@ -540,7 +540,7 @@ void refreshRulesets(string_array &ruleset_list, std::vector<ruleset_content> &r
writeLog(0, "Adding rule '" + rule_url.substr(2) + "," + rule_group + "'.", LOG_LEVEL_INFO); writeLog(0, "Adding rule '" + rule_url.substr(2) + "," + rule_group + "'.", LOG_LEVEL_INFO);
//std::cerr<<"Adding rule '"<<rule_url.substr(2)<<","<<rule_group<<"'."<<std::endl; //std::cerr<<"Adding rule '"<<rule_url.substr(2)<<","<<rule_group<<"'."<<std::endl;
rc = {rule_group, "", "", RULESET_SURGE, std::async(std::launch::async, [rule_url](){return rule_url;})}; rc = {rule_group, "", "", RULESET_SURGE, std::async(std::launch::async, [rule_url](){return rule_url;})};
rca.emplace_back(rc); rca.emplace_back(std::move(rc));
continue; continue;
} }
else else
@@ -571,7 +571,7 @@ void refreshRulesets(string_array &ruleset_list, std::vector<ruleset_content> &r
*/ */
rc = {rule_group, rule_url, rule_url_typed, type, fetchFileAsync(rule_url, proxy, cache_ruleset, async_fetch_ruleset)}; rc = {rule_group, rule_url, rule_url_typed, type, fetchFileAsync(rule_url, proxy, cache_ruleset, async_fetch_ruleset)};
} }
rca.emplace_back(rc); rca.emplace_back(std::move(rc));
/* /*
if(rc.rule_content.get().size()) if(rc.rule_content.get().size())
rca.emplace_back(rc); rca.emplace_back(rc);
@@ -1555,12 +1555,14 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
return "No nodes were found!"; return "No nodes were found!";
} }
prepend_insert.define(prepend_insert_url); prepend_insert.define(prepend_insert_url);
for(nodeInfo &x : insert_nodes) if(prepend_insert)
{ {
if(prepend_insert) std::move(nodes.begin(), nodes.end(), std::back_inserter(insert_nodes));
nodes.emplace(nodes.begin(), x); nodes.swap(insert_nodes);
else }
nodes.emplace_back(x); else
{
std::move(insert_nodes.begin(), insert_nodes.end(), std::back_inserter(nodes));
} }
//run filter script //run filter script
if(filter_script.size()) if(filter_script.size())
@@ -2335,7 +2337,7 @@ int simpleGenerator()
{ {
x = trim(x); x = trim(x);
if(std::find(sections.cbegin(), sections.cend(), x) != sections.cend()) if(std::find(sections.cbegin(), sections.cend(), x) != sections.cend())
new_targets.emplace_back(x); new_targets.emplace_back(std::move(x));
else else
{ {
//std::cerr<<"Artifact \""<<x<<"\" not found in generator settings!\n"; //std::cerr<<"Artifact \""<<x<<"\" not found in generator settings!\n";
+4 -6
View File
@@ -16,10 +16,7 @@ extern int cache_subscription;
void copyNodes(std::vector<nodeInfo> &source, std::vector<nodeInfo> &dest) void copyNodes(std::vector<nodeInfo> &source, std::vector<nodeInfo> &dest)
{ {
for(auto &x : source) std::move(source.begin(), source.end(), std::back_inserter(dest));
{
dest.emplace_back(x);
}
} }
int addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, std::string proxy, string_array &exclude_remarks, string_array &include_remarks, string_array &stream_rules, string_array &time_rules, std::string &subInfo, bool authorized, string_map &request_headers) int addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, std::string proxy, string_array &exclude_remarks, string_array &include_remarks, string_array &stream_rules, string_array &time_rules, std::string &subInfo, bool authorized, string_map &request_headers)
@@ -69,8 +66,9 @@ int addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, std
if(link == "nullnode") if(link == "nullnode")
{ {
node.groupID = 0;
writeLog(0, "Adding node placeholder..."); writeLog(0, "Adding node placeholder...");
allNodes.emplace_back(nodeInfo{-1, -1, 0}); allNodes.emplace_back(std::move(node));
return 0; return 0;
} }
@@ -175,7 +173,7 @@ int addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, std
node.groupID = groupID; node.groupID = groupID;
if(custom_group.size()) if(custom_group.size())
node.group = custom_group; node.group = custom_group;
allNodes.emplace_back(node); allNodes.emplace_back(std::move(node));
} }
return 0; return 0;
} }
+16 -16
View File
@@ -173,7 +173,7 @@ void explodeVmessConf(std::string content, const std::string &custom_port, bool
node.server = add; node.server = add;
node.port = to_int(port, 1); node.port = to_int(port, 1);
node.proxyStr = vmessConstruct(node.group, node.remarks, add, port, type, id, aid, net, cipher, path, host, edge, tls, udp, tfo, scv); node.proxyStr = vmessConstruct(node.group, node.remarks, add, port, type, id, aid, net, cipher, path, host, edge, tls, udp, tfo, scv);
nodes.push_back(node); nodes.emplace_back(std::move(node));
} }
return; return;
} }
@@ -248,7 +248,7 @@ void explodeVmessConf(std::string content, const std::string &custom_port, bool
node.id = index; node.id = index;
node.server = add; node.server = add;
node.port = to_int(port, 1); node.port = to_int(port, 1);
nodes.push_back(node); nodes.emplace_back(std::move(node));
} }
return; return;
} }
@@ -379,7 +379,7 @@ void explodeSSD(std::string link, bool libev, const std::string &custom_port, st
node.port = to_int(port, 1); node.port = to_int(port, 1);
node.proxyStr = ssConstruct(group, remarks, server, port, password, method, plugin, pluginopts, libev); node.proxyStr = ssConstruct(group, remarks, server, port, password, method, plugin, pluginopts, libev);
node.id = index; node.id = index;
nodes.push_back(node); nodes.emplace_back(std::move(node));
index++; index++;
} }
return; return;
@@ -422,7 +422,7 @@ void explodeSSAndroid(std::string ss, bool libev, const std::string &custom_port
node.server = server; node.server = server;
node.port = to_int(port, 1); node.port = to_int(port, 1);
node.proxyStr = ssConstruct(group, ps, server, port, password, method, plugin, pluginopts, libev); node.proxyStr = ssConstruct(group, ps, server, port, password, method, plugin, pluginopts, libev);
nodes.push_back(node); nodes.emplace_back(std::move(node));
index++; index++;
} }
} }
@@ -464,7 +464,7 @@ void explodeSSConf(std::string content, const std::string &custom_port, bool lib
node.server = server; node.server = server;
node.port = to_int(port, 1); node.port = to_int(port, 1);
node.proxyStr = ssConstruct(group, ps, server, port, password, method, plugin, pluginopts, libev); node.proxyStr = ssConstruct(group, ps, server, port, password, method, plugin, pluginopts, libev);
nodes.push_back(node); nodes.emplace_back(std::move(node));
index++; index++;
} }
return; return;
@@ -556,7 +556,7 @@ void explodeSSRConf(std::string content, const std::string &custom_port, bool ss
node.group = SSR_DEFAULT_GROUP; node.group = SSR_DEFAULT_GROUP;
node.proxyStr = ssrConstruct(node.group, node.remarks, base64_encode(node.remarks), server, port, protocol, method, obfs, password, obfsparam, protoparam, ssr_libev); node.proxyStr = ssrConstruct(node.group, node.remarks, base64_encode(node.remarks), server, port, protocol, method, obfs, password, obfsparam, protoparam, ssr_libev);
} }
nodes.push_back(node); nodes.emplace_back(std::move(node));
return; return;
} }
@@ -589,7 +589,7 @@ void explodeSSRConf(std::string content, const std::string &custom_port, bool ss
node.server = server; node.server = server;
node.port = to_int(port, 1); node.port = to_int(port, 1);
node.proxyStr = ssrConstruct(group, remarks, remarks_base64, server, port, protocol, method, obfs, password, obfsparam, protoparam, ssr_libev); node.proxyStr = ssrConstruct(group, remarks, remarks_base64, server, port, protocol, method, obfs, password, obfsparam, protoparam, ssr_libev);
nodes.push_back(node); nodes.emplace_back(std::move(node));
index++; index++;
} }
return; return;
@@ -1109,7 +1109,7 @@ void explodeClash(Node yamlnode, const std::string &custom_port, std::vector<nod
node.server = server; node.server = server;
node.port = to_int(port, 1); node.port = to_int(port, 1);
node.id = index; node.id = index;
nodes.push_back(node); nodes.emplace_back(std::move(node));
index++; index++;
} }
return; return;
@@ -1703,7 +1703,7 @@ bool explodeSurge(std::string surge, const std::string &custom_port, std::vector
node.server = server; node.server = server;
node.port = to_int(port); node.port = to_int(port);
node.id = index; node.id = index;
nodes.push_back(node); nodes.emplace_back(std::move(node));
index++; index++;
} }
return index; return index;
@@ -1769,7 +1769,7 @@ void explodeSSTap(std::string sstap, const std::string &custom_port, std::vector
node.id = index; node.id = index;
node.server = server; node.server = server;
node.port = to_int(port, 1); node.port = to_int(port, 1);
nodes.push_back(node); nodes.emplace_back(std::move(node));
} }
} }
@@ -1791,7 +1791,7 @@ void explodeNetchConf(std::string netch, bool ss_libev, bool ssr_libev, const st
explodeNetch("Netch://" + base64_encode(SerializeObject(json["Server"][i])), ss_libev, ssr_libev, custom_port, node); explodeNetch("Netch://" + base64_encode(SerializeObject(json["Server"][i])), ss_libev, ssr_libev, custom_port, node);
node.id = index; node.id = index;
nodes.push_back(node); nodes.emplace_back(std::move(node));
index++; index++;
} }
} }
@@ -1965,7 +1965,7 @@ void explodeSub(std::string sub, bool sslibev, bool ssrlibev, const std::string
{ {
continue; continue;
} }
nodes.push_back(node); nodes.emplace_back(std::move(node));
} }
} }
} }
@@ -2005,20 +2005,20 @@ void filterNodes(std::vector<nodeInfo> &nodes, string_array &exclude_remarks, st
std::unique_ptr<pcre2_code, decltype(&pcre2_code_free)> pattern(pcre2_compile(reinterpret_cast<const unsigned char*>(exclude_remarks[i].c_str()), PCRE2_ZERO_TERMINATED | PCRE2_MULTILINE, 0, &errornumber, &erroroffset, NULL), &pcre2_code_free); std::unique_ptr<pcre2_code, decltype(&pcre2_code_free)> pattern(pcre2_compile(reinterpret_cast<const unsigned char*>(exclude_remarks[i].c_str()), PCRE2_ZERO_TERMINATED | PCRE2_MULTILINE, 0, &errornumber, &erroroffset, NULL), &pcre2_code_free);
if(!pattern) if(!pattern)
return; return;
exclude_patterns.push_back(std::move(pattern)); exclude_patterns.emplace_back(std::move(pattern));
pcre2_jit_compile(exclude_patterns[i].get(), 0); pcre2_jit_compile(exclude_patterns[i].get(), 0);
std::unique_ptr<pcre2_match_data, decltype(&pcre2_match_data_free)> match_data(pcre2_match_data_create_from_pattern(exclude_patterns[i].get(), NULL), &pcre2_match_data_free); std::unique_ptr<pcre2_match_data, decltype(&pcre2_match_data_free)> match_data(pcre2_match_data_create_from_pattern(exclude_patterns[i].get(), NULL), &pcre2_match_data_free);
exclude_match_data.push_back(std::move(match_data)); exclude_match_data.emplace_back(std::move(match_data));
} }
for(i = 0; i < include_remarks.size(); i++) for(i = 0; i < include_remarks.size(); i++)
{ {
std::unique_ptr<pcre2_code, decltype(&pcre2_code_free)> pattern(pcre2_compile(reinterpret_cast<const unsigned char*>(include_remarks[i].c_str()), PCRE2_ZERO_TERMINATED | PCRE2_MULTILINE, 0, &errornumber, &erroroffset, NULL), &pcre2_code_free); std::unique_ptr<pcre2_code, decltype(&pcre2_code_free)> pattern(pcre2_compile(reinterpret_cast<const unsigned char*>(include_remarks[i].c_str()), PCRE2_ZERO_TERMINATED | PCRE2_MULTILINE, 0, &errornumber, &erroroffset, NULL), &pcre2_code_free);
if(!pattern) if(!pattern)
return; return;
include_patterns.push_back(std::move(pattern)); include_patterns.emplace_back(std::move(pattern));
pcre2_jit_compile(include_patterns[i].get(), 0); pcre2_jit_compile(include_patterns[i].get(), 0);
std::unique_ptr<pcre2_match_data, decltype(&pcre2_match_data_free)> match_data(pcre2_match_data_create_from_pattern(include_patterns[i].get(), NULL), &pcre2_match_data_free); std::unique_ptr<pcre2_match_data, decltype(&pcre2_match_data_free)> match_data(pcre2_match_data_create_from_pattern(include_patterns[i].get(), NULL), &pcre2_match_data_free);
include_match_data.push_back(std::move(match_data)); include_match_data.emplace_back(std::move(match_data));
} }
writeLog(LOG_TYPE_INFO, "Filter started."); writeLog(LOG_TYPE_INFO, "Filter started.");
while(iter != nodes.end()) while(iter != nodes.end())
+14 -14
View File
@@ -642,7 +642,7 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
strLine += "," + rule_group; strLine += "," + rule_group;
if(count_least(strLine, ',', 3)) if(count_least(strLine, ',', 3))
strLine = regReplace(strLine, "^(.*?,.*?)(,.*)(,.*)$", "$1$3$2"); strLine = regReplace(strLine, "^(.*?,.*?)(,.*)(,.*)$", "$1$3$2");
allRules.emplace_back(strLine); allRules.emplace_back(std::move(strLine));
total_rules++; total_rules++;
continue; continue;
} }
@@ -683,7 +683,7 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
strLine += "," + rule_group; strLine += "," + rule_group;
if(count_least(strLine, ',', 3)) if(count_least(strLine, ',', 3))
strLine = regReplace(strLine, "^(.*?,.*?)(,.*)(,.*)$", "$1$3$2"); strLine = regReplace(strLine, "^(.*?,.*?)(,.*)(,.*)$", "$1$3$2");
allRules.emplace_back(strLine); allRules.emplace_back(std::move(strLine));
//Rules.push_back(strLine); //Rules.push_back(strLine);
} }
} }
@@ -828,7 +828,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
strLine = regReplace(strLine, rule_match_regex, "$1$3$2"); strLine = regReplace(strLine, rule_match_regex, "$1$3$2");
} }
strLine = replace_all_distinct(strLine, ",,", ","); strLine = replace_all_distinct(strLine, ",,", ",");
allRules.emplace_back(strLine); allRules.emplace_back(std::move(strLine));
total_rules++; total_rules++;
continue; continue;
} }
@@ -845,7 +845,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
if(surge_ver > 2 && remote_path_prefix.size()) if(surge_ver > 2 && remote_path_prefix.size())
{ {
strLine = "RULE-SET," + remote_path_prefix + "/getruleset?type=1&url=" + urlsafe_base64_encode(rule_path_typed) + "," + rule_group; strLine = "RULE-SET," + remote_path_prefix + "/getruleset?type=1&url=" + urlsafe_base64_encode(rule_path_typed) + "," + rule_group;
allRules.emplace_back(strLine); allRules.emplace_back(std::move(strLine));
continue; continue;
} }
else if(surge_ver == -1 && remote_path_prefix.size()) else if(surge_ver == -1 && remote_path_prefix.size())
@@ -876,7 +876,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
else else
strLine = "RULE-SET," + rule_path + "," + rule_group; strLine = "RULE-SET," + rule_path + "," + rule_group;
allRules.emplace_back(strLine); allRules.emplace_back(std::move(strLine));
continue; continue;
} }
else if(surge_ver == -1 && remote_path_prefix.size()) else if(surge_ver == -1 && remote_path_prefix.size())
@@ -961,7 +961,7 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
if(count_least(strLine, ',', 3)) if(count_least(strLine, ',', 3))
strLine = regReplace(strLine, rule_match_regex, "$1$3$2"); strLine = regReplace(strLine, rule_match_regex, "$1$3$2");
} }
allRules.emplace_back(strLine); allRules.emplace_back(std::move(strLine));
total_rules++; total_rules++;
} }
} }
@@ -1306,7 +1306,7 @@ void netchToClash(std::vector<nodeInfo> &nodes, YAML::Node &yamlnode, const stri
singleproxy["udp"] = true; singleproxy["udp"] = true;
singleproxy.SetStyle(YAML::EmitterStyle::Flow); singleproxy.SetStyle(YAML::EmitterStyle::Flow);
proxies.push_back(singleproxy); proxies.push_back(singleproxy);
remarks_list.emplace_back(remark); remarks_list.emplace_back(std::move(remark));
nodelist.emplace_back(x); nodelist.emplace_back(x);
} }
@@ -1557,12 +1557,12 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, const std::string &base_c
if(obfsparam.size()) if(obfsparam.size())
{ {
args.emplace_back("-g"); args.emplace_back("-g");
args.emplace_back(obfsparam); args.emplace_back(std::move(obfsparam));
} }
if(protoparam.size()) if(protoparam.size())
{ {
args.emplace_back("-G"); args.emplace_back("-G");
args.emplace_back(protoparam); args.emplace_back(std::move(protoparam));
} }
proxy += std::accumulate(std::next(args.begin()), args.end(), args[0], [](std::string a, std::string b) proxy += std::accumulate(std::next(args.begin()), args.end(), args[0], [](std::string a, std::string b)
{ {
@@ -1617,7 +1617,6 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, const std::string &base_c
if(udp) if(udp)
proxy += ", udp-relay=true"; proxy += ", udp-relay=true";
remarks_list.emplace_back(remark);
if(ext.nodelist) if(ext.nodelist)
output_nodelist += remark + " = " + proxy + "\n"; output_nodelist += remark + " = " + proxy + "\n";
else else
@@ -1625,6 +1624,7 @@ std::string netchToSurge(std::vector<nodeInfo> &nodes, const std::string &base_c
ini.Set("{NONAME}", remark + " = " + proxy); ini.Set("{NONAME}", remark + " = " + proxy);
nodelist.emplace_back(x); nodelist.emplace_back(x);
} }
remarks_list.emplace_back(std::move(remark));
} }
if(ext.nodelist) if(ext.nodelist)
@@ -2054,7 +2054,7 @@ void netchToQuan(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<rules
} }
ini.Set("{NONAME}", proxyStr); ini.Set("{NONAME}", proxyStr);
remarks_list.emplace_back(remark); remarks_list.emplace_back(std::move(remark));
nodelist.emplace_back(x); nodelist.emplace_back(x);
} }
@@ -2296,7 +2296,7 @@ void netchToQuanX(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<rule
proxyStr += ", tag=" + remark; proxyStr += ", tag=" + remark;
ini.Set("{NONAME}", proxyStr); ini.Set("{NONAME}", proxyStr);
remarks_list.emplace_back(remark); remarks_list.emplace_back(std::move(remark));
nodelist.emplace_back(x); nodelist.emplace_back(x);
} }
@@ -2647,7 +2647,7 @@ void netchToMellow(std::vector<nodeInfo> &nodes, INIReader &ini, std::vector<rul
} }
ini.Set("{NONAME}", proxy); ini.Set("{NONAME}", proxy);
remarks_list.emplace_back(remark); remarks_list.emplace_back(std::move(remark));
nodelist.emplace_back(x); nodelist.emplace_back(x);
} }
@@ -2852,7 +2852,7 @@ std::string netchToLoon(std::vector<nodeInfo> &nodes, const std::string &base_co
{ {
ini.Set("{NONAME}", remark + " = " + proxy); ini.Set("{NONAME}", remark + " = " + proxy);
nodelist.emplace_back(x); nodelist.emplace_back(x);
remarks_list.emplace_back(remark); remarks_list.emplace_back(std::move(remark));
} }
} }
+7 -7
View File
@@ -263,7 +263,7 @@ int renderClashScript(YAML::Node &base_rule, std::vector<ruleset_content> &rules
strLine += "," + rule_group; strLine += "," + rule_group;
if(count_least(strLine, ',', 3)) if(count_least(strLine, ',', 3))
strLine = regReplace(strLine, "^(.*?,.*?)(,.*)(,.*)$", "$1$3$2"); strLine = regReplace(strLine, "^(.*?,.*?)(,.*)(,.*)$", "$1$3$2");
rules.emplace_back(strLine); rules.emplace_back(std::move(strLine));
continue; continue;
} }
else else
@@ -290,7 +290,7 @@ int renderClashScript(YAML::Node &base_rule, std::vector<ruleset_content> &rules
rules.emplace_back("RULE-SET," + rule_group + "_" + rule_name + "_classical," + rule_group); rules.emplace_back("RULE-SET," + rule_group + "_" + rule_name + "_classical," + rule_group);
break; break;
} }
groups.emplace_back(rule_name); groups.emplace_back(std::move(rule_name));
continue; continue;
} }
if(remote_path_prefix.size()) if(remote_path_prefix.size())
@@ -302,9 +302,9 @@ int renderClashScript(YAML::Node &base_rule, std::vector<ruleset_content> &rules
urls[rule_name] = rule_path_typed; urls[rule_name] = rule_path_typed;
if(clash_classical_ruleset) if(clash_classical_ruleset)
{ {
groups.emplace_back(rule_name);
if(!script) if(!script)
rules.emplace_back("RULE-SET," + rule_group + "_" + rule_name + "_classical," + rule_group); rules.emplace_back("RULE-SET," + rule_group + "_" + rule_name + "_classical," + rule_group);
groups.emplace_back(std::move(rule_name));
continue; continue;
} }
} }
@@ -350,12 +350,12 @@ int renderClashScript(YAML::Node &base_rule, std::vector<ruleset_content> &rules
strLine += "," + rule_group; strLine += "," + rule_group;
if(count_least(strLine, ',', 3)) if(count_least(strLine, ',', 3))
strLine = regReplace(strLine, "^(.*?,.*?)(,.*)(,.*)$", "$1$3$2"); strLine = regReplace(strLine, "^(.*?,.*?)(,.*)(,.*)$", "$1$3$2");
rules.emplace_back(strLine); rules.emplace_back(std::move(strLine));
} }
} }
else if(startsWith(strLine, "DOMAIN,") || startsWith(strLine, "DOMAIN-SUFFIX,")) else if(!has_domain[rule_name] && (startsWith(strLine, "DOMAIN,") || startsWith(strLine, "DOMAIN-SUFFIX,")))
has_domain[rule_name] = true; has_domain[rule_name] = true;
else if(startsWith(strLine, "IP-CIDR,") || startsWith(strLine, "IP-CIDR6,")) else if(!has_ipcidr[rule_name] && (startsWith(strLine, "IP-CIDR,") || startsWith(strLine, "IP-CIDR6,")))
has_ipcidr[rule_name] = true; has_ipcidr[rule_name] = true;
} }
if(has_domain[rule_name] && !script) if(has_domain[rule_name] && !script)
@@ -363,7 +363,7 @@ int renderClashScript(YAML::Node &base_rule, std::vector<ruleset_content> &rules
if(has_ipcidr[rule_name] && !script) if(has_ipcidr[rule_name] && !script)
rules.emplace_back("RULE-SET," + rule_group + "_" + rule_name + "_ipcidr," + rule_group); rules.emplace_back("RULE-SET," + rule_group + "_" + rule_name + "_ipcidr," + rule_group);
if(std::find(groups.begin(), groups.end(), rule_name) == groups.end()) if(std::find(groups.begin(), groups.end(), rule_name) == groups.end())
groups.emplace_back(rule_name); groups.emplace_back(std::move(rule_name));
} }
} }
for(std::string &x : groups) for(std::string &x : groups)
+2 -2
View File
@@ -247,14 +247,14 @@ end:
working_thread--; working_thread--;
} }
void append_response(std::string type, std::string request, std::string content_type, response_callback response) void append_response(const std::string &type, const std::string &request, const std::string &content_type, response_callback response)
{ {
responseRoute rr; responseRoute rr;
rr.method = type; rr.method = type;
rr.path = request; rr.path = request;
rr.content_type = content_type; rr.content_type = content_type;
rr.rc = response; rr.rc = response;
responses.push_back(rr); responses.push_back(std::move(rr));
} }
void stop_web_server() void stop_web_server()
+1 -1
View File
@@ -322,7 +322,7 @@ void append_response(const std::string &method, const std::string &uri, const st
rr.path = uri; rr.path = uri;
rr.content_type = content_type; rr.content_type = content_type;
rr.rc = response; rr.rc = response;
responses.emplace_back(rr); responses.emplace_back(std::move(rr));
} }
void append_redirect(const std::string &uri, const std::string &target) void append_redirect(const std::string &uri, const std::string &target)