summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcollin <collin+i@collinmcqueen.com>2021-04-22 09:59:40 -0400
committercollin <collin+i@collinmcqueen.com>2021-04-22 09:59:40 -0400
commit030337409de8dc4a408f0ae4e74c39320e9b3949 (patch)
treec43f400835b1c5ce54e6219d18a90f2eac961215
parent9f16f983b5ce0523cb84c65f77e431d69943be26 (diff)
downloadsdl_core-030337409de8dc4a408f0ae4e74c39320e9b3949.tar.gz
small optimization, parse key first
-rw-r--r--src/components/config_profile/src/profile.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc
index ec078b8aaf..81d3377a1f 100644
--- a/src/components/config_profile/src/profile.cc
+++ b/src/components/config_profile/src/profile.cc
@@ -1262,13 +1262,6 @@ void Profile::UpdateValues() {
std::string key(line_str.data(), equals_idx);
std::string value(line_str.data() + equals_idx + 1);
- auto val_whitespace_len = value.find_first_not_of(" \t\r\n");
- if (std::string::npos == val_whitespace_len) {
- value = "";
- } else {
- value.erase(0, value.find_first_not_of(" \t\r\n"));
- value.erase(value.find_last_not_of(" \t\r\n") + 1);
- }
auto key_whitespace_len = key.find_first_not_of(" \t\r\n");
if (std::string::npos == key_whitespace_len) {
@@ -1277,9 +1270,19 @@ void Profile::UpdateValues() {
key.erase(0, key_whitespace_len);
key.erase(key.find_last_not_of(" \t\r\n") + 1);
- if (false == config_obj_[chapter].keyExists(key)) {
- config_obj_[chapter][key] = value;
+ if (true == config_obj_[chapter].keyExists(key)) {
+ continue;
}
+
+ auto val_whitespace_len = value.find_first_not_of(" \t\r\n");
+ if (std::string::npos == val_whitespace_len) {
+ value = "";
+ } else {
+ value.erase(0, value.find_first_not_of(" \t\r\n"));
+ value.erase(value.find_last_not_of(" \t\r\n") + 1);
+ }
+
+ config_obj_[chapter][key] = value;
}
}