diff options
author | Alexander Baldeck <alexander@archlinux.org> | 2004-12-28 19:39:56 +0000 |
---|---|---|
committer | Alexander Baldeck <alexander@archlinux.org> | 2004-12-28 19:39:56 +0000 |
commit | 3ef9d42fab5fddf78abd3fad316234cf36055808 (patch) | |
tree | 33fe7c7a5b00c7d285ed015729edd895f101691f /src/configuration.cpp | |
parent | b9f65e717acb7848f5bbb2450d854d87df92793e (diff) | |
download | mana-3ef9d42fab5fddf78abd3fad316234cf36055808.tar.gz mana-3ef9d42fab5fddf78abd3fad316234cf36055808.tar.bz2 mana-3ef9d42fab5fddf78abd3fad316234cf36055808.tar.xz mana-3ef9d42fab5fddf78abd3fad316234cf36055808.zip |
- some optimization :)
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r-- | src/configuration.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index 3dccdecf..a7f07aeb 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -59,7 +59,13 @@ void Configuration::init(std::string filename) { optionTmp.numericValue = atof(inBuffer.c_str()); - iniOptions.push_back(optionTmp); + if(!keyExists(optionTmp.key)) { + iniOptions.push_back(optionTmp); + } else { + iter->key = optionTmp.key; + iter->stringValue = optionTmp.stringValue; + iter->numericValue = optionTmp.numericValue; + } } } } @@ -119,15 +125,11 @@ void Configuration::setValue(std::string key, std::string value) { iniOptions.push_back(optionTmp); } else { - for (iter = iniOptions.begin(); iter != iniOptions.end(); iter++) { - if(iter->key == key) { - #ifdef __DEBUG - std::cout << "Configuration::setValue(" << key << ", \"" << value << "\") reset\n"; - #endif - iter->stringValue = value; - iter->numericValue = 0; - } - } + #ifdef __DEBUG + std::cout << "Configuration::setValue(" << key << ", \"" << value << "\") reset\n"; + #endif + iter->stringValue = value; + iter->numericValue = 0; } } @@ -147,15 +149,11 @@ void Configuration::setValue(std::string key, float value) { iniOptions.push_back(optionTmp); } else { - for (iter = iniOptions.begin(); iter != iniOptions.end(); iter++) { - if(iter->key == key) { - #ifdef __DEBUG - std::cout << "Configuration::setValue(" << key << ", " << value << ") reset\n"; - #endif - iter->stringValue = ""; - iter->numericValue = value; - } - } + #ifdef __DEBUG + std::cout << "Configuration::setValue(" << key << ", " << value << ") reset\n"; + #endif + iter->stringValue = ""; + iter->numericValue = value; } } |