mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
update
- Optimize std::string in function params by passing in a const reference
This commit is contained in:
parent
41fe047f7a
commit
19733adcf8
@ -69,7 +69,7 @@ void ProjectConfig::load()
|
||||
log_d("Project config found - Config length: %d", configLen);
|
||||
|
||||
char buff[configLen];
|
||||
getBytes("config", buff, configLen);
|
||||
getBytes("projectConf", buff, configLen);
|
||||
|
||||
for (int i = 0; i < configLen; i++)
|
||||
Serial.printf("%02X ", buff[i]);
|
||||
@ -83,7 +83,7 @@ void ProjectConfig::save()
|
||||
log_d("Saving project config");
|
||||
|
||||
TrackerConfig_t *tracker_config = (TrackerConfig_t *)&this->config;
|
||||
putBytes("config", tracker_config, 3 * sizeof(TrackerConfig_t));
|
||||
putBytes("projectConf", tracker_config, 3 * sizeof(TrackerConfig_t));
|
||||
|
||||
log_i("Project config saved and system is rebooting");
|
||||
delay(20000);
|
||||
|
||||
@ -32,7 +32,7 @@ char *Helpers::itoa(int value, char *result, int base)
|
||||
return result;
|
||||
}
|
||||
|
||||
void split(std::string str, std::string splitBy, std::vector<std::string> &tokens)
|
||||
void split(const std::string &str, const std::string &splitBy, std::vector<std::string> &tokens)
|
||||
{
|
||||
/* Store the original string in the array, so we can loop the rest
|
||||
* of the algorithm. */
|
||||
|
||||
@ -12,8 +12,8 @@ class WiFiHandler
|
||||
{
|
||||
public:
|
||||
WiFiHandler(ProjectConfig *configManager, StateManager<WiFiState_e> *stateManager,
|
||||
std::string ssid,
|
||||
std::string password,
|
||||
const std::string &ssid,
|
||||
const std::string &password,
|
||||
uint8_t channel);
|
||||
virtual ~WiFiHandler();
|
||||
void setupWifi();
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
|
||||
WiFiHandler::WiFiHandler(ProjectConfig *configManager,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string ssid,
|
||||
std::string password,
|
||||
const std::string &ssid,
|
||||
const std::string &password,
|
||||
uint8_t channel) : configManager(configManager),
|
||||
stateManager(stateManager),
|
||||
ssid(ssid),
|
||||
|
||||
@ -4,7 +4,7 @@ BaseAPI::BaseAPI(int CONTROL_PORT,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url) : API_Utilities(CONTROL_PORT,
|
||||
const std::string &api_url) : API_Utilities(CONTROL_PORT,
|
||||
network,
|
||||
camera,
|
||||
stateManager,
|
||||
|
||||
@ -74,7 +74,7 @@ public:
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url);
|
||||
const std::string &api_url);
|
||||
|
||||
virtual ~BaseAPI();
|
||||
virtual void begin();
|
||||
|
||||
@ -22,7 +22,7 @@ API_Utilities::API_Utilities(int CONTROL_PORT,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url) : server(new AsyncWebServer(CONTROL_PORT)),
|
||||
const std::string &api_url) : server(new AsyncWebServer(CONTROL_PORT)),
|
||||
stateManager(stateManager),
|
||||
network(network),
|
||||
camera(camera),
|
||||
|
||||
@ -33,7 +33,7 @@ public:
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url);
|
||||
const std::string &api_url);
|
||||
virtual ~API_Utilities();
|
||||
|
||||
static void printASCII();
|
||||
|
||||
@ -8,7 +8,7 @@ APIServer::APIServer(int CONTROL_PORT,
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url) : BaseAPI(CONTROL_PORT,
|
||||
const std::string &api_url) : BaseAPI(CONTROL_PORT,
|
||||
network,
|
||||
camera,
|
||||
stateManager,
|
||||
@ -47,11 +47,11 @@ void APIServer::setupServer()
|
||||
addRouteMap("builtin", routes, indexes); // add new route map to the route_map
|
||||
}
|
||||
|
||||
void APIServer::findParam(AsyncWebServerRequest *request, const char *param, String &value)
|
||||
void APIServer::findParam(AsyncWebServerRequest *request, const char *param, std::string &value)
|
||||
{
|
||||
if (request->hasParam(param))
|
||||
{
|
||||
value = request->getParam(param)->value();
|
||||
value = request->getParam(param)->value().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ void APIServer::findParam(AsyncWebServerRequest *request, const char *param, Str
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
void APIServer::addRouteMap(std::string index, route_t route, std::vector<std::string> &indexes)
|
||||
void APIServer::addRouteMap(const std::string &index, route_t route, std::vector<std::string> &indexes)
|
||||
{
|
||||
route_map.emplace(index, route);
|
||||
|
||||
|
||||
@ -11,13 +11,13 @@ public:
|
||||
WiFiHandler *network,
|
||||
CameraHandler *camera,
|
||||
StateManager<WiFiState_e> *stateManager,
|
||||
std::string api_url);
|
||||
const std::string &api_url);
|
||||
|
||||
virtual ~APIServer();
|
||||
void begin();
|
||||
void setupServer();
|
||||
void findParam(AsyncWebServerRequest *request, const char *param, String &value);
|
||||
void addRouteMap(std::string index, route_t route, std::vector<std::string> &indexes);
|
||||
void findParam(AsyncWebServerRequest *request, const char *param, std::string &value);
|
||||
void addRouteMap(const std::string &index, route_t route, std::vector<std::string> &indexes);
|
||||
void handleRequest(AsyncWebServerRequest *request);
|
||||
|
||||
public:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user