Reduce amount of copies for HashedString for improved performance
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <deukhoofd@gmail.com>
This commit is contained in:
2019-06-25 15:18:36 +02:00
parent bace7b294d
commit 48224afe45
13 changed files with 62 additions and 57 deletions

View File

@@ -39,7 +39,7 @@ namespace Porygon::Binder {
_currentScope--;
}
int BoundScope::Exists(Utilities::HashedString key) {
int BoundScope::Exists(const Utilities::HashedString& key) {
auto found = this->_tableScope->find(key);
if (found != _tableScope->end()) {
return 0;
@@ -54,7 +54,7 @@ namespace Porygon::Binder {
return -1;
}
BoundVariable *BoundScope::GetVariable(uint32_t scope, Utilities::HashedString identifier) {
BoundVariable *BoundScope::GetVariable(uint32_t scope, const Utilities::HashedString& identifier) {
if (scope == 0) {
auto find = this->_tableScope->find(identifier);
if (find != _tableScope->end()) {
@@ -71,7 +71,7 @@ namespace Porygon::Binder {
}
}
VariableAssignment BoundScope::CreateExplicitLocal(Utilities::HashedString identifier, std::shared_ptr<ScriptType> type) {
VariableAssignment BoundScope::CreateExplicitLocal(const Utilities::HashedString& identifier, std::shared_ptr<ScriptType> type) {
auto scope = this->_localScope.at(this->_currentScope - 1);
if (scope->find(identifier) != scope->end()) {
return VariableAssignment(VariableAssignmentResult::ExplicitLocalVariableExists, nullptr);
@@ -81,7 +81,7 @@ namespace Porygon::Binder {
new BoundVariableKey(identifier, this->_currentScope, true));
}
VariableAssignment BoundScope::AssignVariable(Utilities::HashedString identifier, const std::shared_ptr<ScriptType> &type) {
VariableAssignment BoundScope::AssignVariable(const Utilities::HashedString& identifier, const std::shared_ptr<ScriptType> &type) {
int exists = this->Exists(identifier);
if (exists == -1) {
// Creation

View File

@@ -28,13 +28,13 @@ namespace Porygon::Binder {
void GoOuterScope();
int Exists(Utilities::HashedString key);
int Exists(const Utilities::HashedString& key);
BoundVariable *GetVariable(uint32_t scope, Utilities::HashedString identifier);
BoundVariable *GetVariable(uint32_t scope, const Utilities::HashedString& identifier);
VariableAssignment CreateExplicitLocal(Utilities::HashedString identifier, std::shared_ptr<ScriptType> type);
VariableAssignment CreateExplicitLocal(const Utilities::HashedString& identifier, std::shared_ptr<ScriptType> type);
VariableAssignment AssignVariable(Utilities::HashedString identifier, const std::shared_ptr<ScriptType> &type);
VariableAssignment AssignVariable(const Utilities::HashedString& identifier, const std::shared_ptr<ScriptType> &type);
size_t GetLocalVariableCount() {
return _localScope.size();