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:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user