avoid collecting duplicate parameters in Booster::cfg_

This commit is contained in:
Vadim Khotilovich 2016-04-25 22:08:53 -05:00
parent b3c9e6a0db
commit 0527b17c9d

View File

@ -32,7 +32,16 @@ class Booster {
} }
inline void SetParam(const std::string& name, const std::string& val) { inline void SetParam(const std::string& name, const std::string& val) {
auto it = std::find_if(cfg_.begin(), cfg_.end(),
[&name](decltype(*cfg_.begin()) &x) {
return x.first == name;
}
);
if (it == cfg_.end()) {
cfg_.push_back(std::make_pair(name, val)); cfg_.push_back(std::make_pair(name, val));
} else {
(*it).second = val;
}
if (configured_) { if (configured_) {
learner_->Configure(cfg_); learner_->Configure(cfg_);
} }