Remove unnecessary heap-allocation & copy in Transaction::extractArguments

- utils::urldecode_nonstrict_inplace decodes inplace so key & value,
  which are values returned by utils::string::ssplit_pair can be
  just be modified and do not need to be copied.
- Updated signature of utils::urldecode_nonstrict_inplace, as its
  two callers already have std::string values.
This commit is contained in:
Eduardo Arias
2024-06-01 21:59:16 +00:00
parent 021d0caa33
commit b647dbd905
4 changed files with 40 additions and 80 deletions

View File

@@ -27,16 +27,8 @@ UrlDecode::UrlDecode(const std::string &action)
}
bool UrlDecode::transform(std::string &value, const Transaction *trans) const {
int invalid_count = 0;
int changed;
const auto new_len = utils::urldecode_nonstrict_inplace(
(unsigned char*)value.data(),
value.length(),
&invalid_count,
&changed);
value.resize(new_len);
return changed != 0;
int invalid_count;
return utils::urldecode_nonstrict_inplace(value, invalid_count);
}