Skip to content

Commit 8f6f71f

Browse files
committed
Pass maps by reference to avoid copy
CURA-13049
1 parent a6bc213 commit 8f6f71f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

include/cura-formulae-engine/ast/ast.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class EnvironmentMap : public Environment
5555

5656
void set(const std::string& key, const eval::Value& value) noexcept;
5757

58-
void add(const std::unordered_map<std::string, eval::Value> values);
58+
void add(const std::unordered_map<std::string, eval::Value>& values);
5959

6060
[[nodiscard]] EnvironmentMap clone() const noexcept;
6161
};
@@ -106,7 +106,7 @@ class LocalEnvironment : public ChainableEnvironment
106106

107107
void set(const std::string& key, const eval::Value& value);
108108

109-
void add(const std::unordered_map<std::string, eval::Value> values);
109+
void add(const std::unordered_map<std::string, eval::Value>& values);
110110
};
111111

112112
} // namespace CuraFormulaeEngine::env

src/ast/ast.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void EnvironmentMap::set(const std::string& key, const eval::Value& value) noexc
3333
environment_.insert_or_assign(key, value);
3434
}
3535

36-
void EnvironmentMap::add(const std::unordered_map<std::string, eval::Value> values)
36+
void EnvironmentMap::add(const std::unordered_map<std::string, eval::Value>& values)
3737
{
3838
environment_.insert(values.begin(), values.end());
3939
}
@@ -63,7 +63,7 @@ void LocalEnvironment::set(const std::string& key, const eval::Value& value)
6363
local_environment_.set(key, value);
6464
}
6565

66-
void LocalEnvironment::add(const std::unordered_map<std::string, eval::Value> values)
66+
void LocalEnvironment::add(const std::unordered_map<std::string, eval::Value>& values)
6767
{
6868
local_environment_.add(values);
6969
}

0 commit comments

Comments
 (0)