std::string_view 的使用
This commit is contained in:
@@ -5,8 +5,9 @@
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string_view>
|
||||
|
||||
Aircraft::Aircraft(const std::string &icao) : Aircraft_Info(icao) {
|
||||
Aircraft::Aircraft(std::string_view icao) : Aircraft_Info(icao) {
|
||||
auto size = Global::instance()->mode_acs.max_track_point_size.load();
|
||||
air_pos_track_list.init(size);
|
||||
surface_pos_track_list.init(size);
|
||||
@@ -32,13 +33,13 @@ void Aircraft::refresh_external_database_info() {
|
||||
}
|
||||
|
||||
std::shared_ptr<SSR::Aircraft_Info>
|
||||
DataBase::get_aircraft(const std::string &icao) {
|
||||
return aircraft_map.get(icao);
|
||||
DataBase::get_aircraft(std::string_view icao) {
|
||||
return aircraft_map.get(std::string(icao));
|
||||
}
|
||||
|
||||
std::shared_ptr<SSR::Aircraft_Info>
|
||||
DataBase::create_aircraft(const std::string &icao) {
|
||||
auto ret = aircraft_map.create(icao);
|
||||
DataBase::create_aircraft(std::string_view icao) {
|
||||
auto ret = aircraft_map.create(std::string(icao));
|
||||
ret->refresh_external_database_info();
|
||||
return ret;
|
||||
}
|
||||
@@ -298,8 +299,8 @@ void database_server(Global *g) {
|
||||
|
||||
static std::string output;
|
||||
|
||||
static void log_i(const std::string &label, const std::string &value,
|
||||
const std::string &unit = "") {
|
||||
static void log_i(std::string_view label, std::string_view value,
|
||||
std::string_view unit = "") {
|
||||
std::ostringstream oss;
|
||||
// Format the label and value
|
||||
oss << std::left << std::setw(30) << label << ": " << value;
|
||||
@@ -313,7 +314,7 @@ static void log_i(const std::string &label, const std::string &value,
|
||||
output += oss.str();
|
||||
}
|
||||
|
||||
static void log_i(const std::string &label, double value,
|
||||
const std::string &unit = "") {
|
||||
static void log_i(std::string_view label, double value,
|
||||
std::string_view unit = "") {
|
||||
log_i(label, std::to_string(value), unit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user