Skip to content

replaced with constant references to avoid copying #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions blobstamper/stamp_enumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

std::string StampStrEnumerator::ExtractStr(std::shared_ptr<Blob> blob)
{
std::vector<std::string> data = ExtractStrVector(blob);
const std::vector<std::string> &data = ExtractStrVector(blob);
std::string res = "";

for (std::string s : data)
for (const std::string &s : data)
{
if (!res.empty())
{
Expand Down
14 changes: 7 additions & 7 deletions blobstamper/stamp_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
PoolPickerStamp::PoolPickerStamp(std::vector<std::shared_ptr<StampBaseStr>> new_pool)
: pool{new_pool}
{
for (auto stamp : pool)
for (const auto &stamp : pool)
{
std::weak_ptr<StampBaseStr> wp = stamp;
weak_pool.push_back(wp);
Expand All @@ -40,7 +40,7 @@ PoolPickerStamp::isRecursive()
if (is_recursive || is_in_recursion)
return true;
is_in_recursion = true;
for (auto stamp : weak_pool)
for (const auto &stamp : weak_pool)
{
if (stamp.lock()->isRecursive())
{
Expand All @@ -62,7 +62,7 @@ PoolPickerStamp::ExtractStr(std::shared_ptr<Blob> blob)
std::vector<std::weak_ptr<StampBaseStr>> target_pool;
std::vector<std::weak_ptr<StampBaseStr>> unbounded_pool;

for (auto stamp_w : weak_pool)
for (const auto &stamp_w : weak_pool)
{
auto stamp = stamp_w.lock();
if (stamp->minSize() <= blob->Size())
Expand Down Expand Up @@ -91,7 +91,7 @@ PoolPickerStamp::minSize()
if (is_in_recursion)
return res;
is_in_recursion = true; /* Do not use isRecursive() inside as it uses same flag*/
for(auto stamp : weak_pool)
for (const auto &stamp : weak_pool)
{
int candidat = stamp.lock()->minSize();
if (res > candidat)
Expand All @@ -111,7 +111,7 @@ PoolPickerStamp::maxSize()
if (is_recursive || is_in_recursion)
return -1;
is_in_recursion = true; /* Do not use isRecursive() inside as it uses same flag*/
for (auto stamp : weak_pool)
for (const auto &stamp : weak_pool)
{
int candidat = stamp.lock()->maxSize();
if (candidat == -1)
Expand Down Expand Up @@ -144,8 +144,8 @@ StampJSONString::ExtractStr(std::shared_ptr<Blob> blob)
std::string
StampJSONHashEl::ExtractStr(std::shared_ptr<Blob> blob)
{
std::string n = stamp_name->ExtractStr(blob);
std::string v = stamp_value->ExtractStr(blob);
const std::string &n = stamp_name->ExtractStr(blob);
const std::string &v = stamp_value->ExtractStr(blob);
return n + ": " + v;
}

Expand Down
2 changes: 1 addition & 1 deletion blobstamper/stamp_math_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ StampMathUnaryOp::ExtractStr(std::shared_ptr<Blob> blob)
std::string
StampMathBinaryOp::ExtractStr(std::shared_ptr<Blob> blob)
{
std::vector<std::shared_ptr<Blob>> blobs = extract_internal(blob);
const std::vector<std::shared_ptr<Blob>> &blobs = extract_internal(blob);
return (std::string)"(" + stamp1->ExtractStr(blobs[0]) + " " + op_name + " " + stamp2->ExtractStr(blobs[1]) + ")";
}

8 changes: 4 additions & 4 deletions blobstamper/stamp_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ StampTextPulp::ExtractStr(std::shared_ptr<Blob> blob)

std::string StampTextPulpWords::ExtractStr(std::shared_ptr<Blob> blob)
{
std::vector<std::string> data = ExtractStrVector(blob);
const std::vector<std::string> &data = ExtractStrVector(blob);
std::string res = "";

for(std::string s : data)
for (const std::string &s : data)
{
if (!res.empty())
{
Expand All @@ -54,10 +54,10 @@ std::string StampTextPulpWords::ExtractStr(std::shared_ptr<Blob> blob)

std::string StampTextDictWords::ExtractStr(std::shared_ptr<Blob> blob)
{
std::vector<std::string> data = ExtractStrVector(blob);
const std::vector<std::string> &data = ExtractStrVector(blob);
std::string res = "";

for(std::string s : data)
for (const std::string &s : data)
{
if (!res.empty())
{
Expand Down