Minor optimization in settings file parsing; don't copy a few strings.

This commit is contained in:
Stephen Anthony 2018-08-31 16:32:12 -02:30
parent 72f6096ba8
commit 404ab8ffcc
2 changed files with 3 additions and 5 deletions

View File

@ -221,10 +221,8 @@ void Settings::loadConfig()
continue;
// Split the line into key/value pairs and trim any whitespace
key = line.substr(0, equalPos);
value = line.substr(equalPos + 1, line.length() - key.length() - 1);
key = trim(key);
value = trim(value);
key = trim(line.substr(0, equalPos));
value = trim(line.substr(equalPos + 1, line.length() - key.length() - 1));
// Skip absent key
if(key.length() == 0)

View File

@ -98,7 +98,7 @@ class Settings
virtual void saveConfig();
// Trim leading and following whitespace from a string
static string trim(string& str)
static string trim(const string& str)
{
string::size_type first = str.find_first_not_of(' ');
return (first == string::npos) ? EmptyString :