Reduce amount of copies for HashedString for improved performance
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <deukhoofd@gmail.com>
This commit is contained in:
@@ -40,21 +40,21 @@ namespace Porygon::Evaluation {
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(EvalValue *val) const final {
|
||||
const auto stringKey = val->EvaluateString();
|
||||
return this->_table->at(Utilities::HashedString(stringKey));
|
||||
return this->_table->at(Utilities::HashedString::CreateLookup(stringKey));
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
|
||||
return this->_table->at(Utilities::HashedString(hash));
|
||||
return this->_table->at(Utilities::HashedString::CreateLookup(hash));
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(const char *val) const {
|
||||
auto hash = Utilities::HashedString::ConstHash(val);
|
||||
return this->_table->at(Utilities::HashedString(hash));
|
||||
return this->_table->at(Utilities::HashedString::CreateLookup(hash));
|
||||
}
|
||||
|
||||
void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue> &value) const final {
|
||||
auto hash = key->GetHashCode();
|
||||
this->_table->at(Utilities::HashedString(hash)) = value;
|
||||
this->_table->at(Utilities::HashedString::CreateLookup(hash)) = value;
|
||||
}
|
||||
|
||||
const _Rb_tree_const_iterator<pair<const Utilities::HashedString, shared_ptr<EvalValue>>> GetTableIterator() const{
|
||||
|
||||
@@ -392,7 +392,7 @@ namespace Porygon::Evaluation {
|
||||
auto values = new map<Utilities::HashedString, shared_ptr<EvalValue>>();
|
||||
for (int i = 0; i < valueExpressions->size(); i++) {
|
||||
auto val = this->EvaluateExpression(valueExpressions->at(i));
|
||||
auto key = Utilities::StringUtils::IntToString(i + 1);
|
||||
auto key = new u16string(Utilities::StringUtils::IntToString(i + 1));
|
||||
values->insert({Utilities::HashedString(key), val});
|
||||
}
|
||||
auto valuesPointer = shared_ptr<map<Utilities::HashedString, shared_ptr<EvalValue>>>(values);
|
||||
|
||||
Reference in New Issue
Block a user