SolidWallOfCode commented on a change in pull request #8638:
URL: https://github.com/apache/trafficserver/pull/8638#discussion_r797178106
##########
File path: plugins/s3_auth/aws_auth_v4.cc
##########
@@ -176,39 +176,27 @@ canonicalEncode(const String &in, bool isObjectName)
* @param inLen input character count
* @return pointer to the trimmed string.
*/
-std::string
+String
trimWhiteSpacesAndSqueezeInnerSpaces(const char *in, size_t inLen)
{
if (nullptr == in || inLen == 0) {
- return std::string(in, inLen);
- }
-
- const char *first = in;
- while (size_t(first - in) < inLen && isspace(*first)) {
- first++;
+ return "";
}
- const char *last = in + inLen - 1;
- while (last > in && isspace(*last)) {
- last--;
- }
+ String in_str = trimWhiteSpaces(String(in, inLen));
+ String out_str;
Review comment:
You want a `reserve` here to have only one allocation for `out_str`.
Otherwise it's possible to have a allocate / deallocate on every `+=`. You'll
need to `resize` after to get the string the actual length.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]