std::string_view 的使用

This commit is contained in:
2026-06-29 09:40:55 +08:00
parent cd446b7ca8
commit 8daf67aa5d
52 changed files with 1420 additions and 1367 deletions
+4 -3
View File
@@ -3,6 +3,7 @@
#include "Core/Net_Adapter/Net_Adapter.h"
#include "Global.h"
#include <filesystem>
#include <string_view>
#undef interface
std::string default_config_path;
@@ -124,9 +125,9 @@ void Device_Config::server(Global *g) {
buffer << ifs.rdbuf();
interface = buffer.str();
}
static auto set = [](std::string &interface, const std::string &token,
const std::string &value) {
std::string var_name = "${" + token + "}";
static auto set = [](std::string &interface, std::string_view token,
std::string_view value) {
std::string var_name = "${" + std::string(token) + "}";
auto size = var_name.size();
size_t pos = interface.find(var_name);
while (pos != std::string::npos) {