From da775eca81e2b4c7b74cf5287e4fa016d5a73b12 Mon Sep 17 00:00:00 2001 From: Eduardo Arias Date: Mon, 19 Aug 2024 08:41:18 -0700 Subject: [PATCH] Perform ReplaceNulls transformation in-place --- src/actions/transformations/replace_nulls.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/actions/transformations/replace_nulls.cc b/src/actions/transformations/replace_nulls.cc index c59ceb87..479f2f5a 100644 --- a/src/actions/transformations/replace_nulls.cc +++ b/src/actions/transformations/replace_nulls.cc @@ -23,21 +23,16 @@ ReplaceNulls::ReplaceNulls(const std::string &action) this->action_kind = 1; } -bool ReplaceNulls::transform(std::string &val, const Transaction *trans) const { - int64_t i; - std::string value(val); +bool ReplaceNulls::transform(std::string &value, const Transaction *trans) const { + bool changed = false; - i = 0; - while (i < value.size()) { - if (value.at(i) == '\0') { - value[i] = ' '; - } else { - i++; + for(auto &c : value) { + if (c == '\0') { + c = ' '; + changed = true; } } - const auto changed = val != value; - val = value; return changed; }