This is an automated email from the ASF dual-hosted git repository.

bankim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new f486f08  [flags] Remove the costly stringstream to string conversion 
in a loop
f486f08 is described below

commit f486f0813a73739d4fd4e69ec290aeb820079abe
Author: Bankim Bhavsar <[email protected]>
AuthorDate: Mon May 10 09:54:37 2021 -0700

    [flags] Remove the costly stringstream to string conversion in a loop
    
    stringstream.str() returns a copy of the underlying string
    buffer which is expensive if done repeatedly in a loop.
    This change avoids the check for emptiness of the stringstream
    in a loop and simply appends the newline character at the
    end of every flag. This means there'll be a newline at
    the end of the string which is okay.
    
    Change-Id: I6f85aa85feaac34abfa8a582f936392d0a4b0ad6
    Reviewed-on: http://gerrit.cloudera.org:8080/17418
    Reviewed-by: Alexey Serbin <[email protected]>
    Tested-by: Kudu Jenkins
---
 src/kudu/util/flags.cc | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/kudu/util/flags.cc b/src/kudu/util/flags.cc
index 949018c..8897689 100644
--- a/src/kudu/util/flags.cc
+++ b/src/kudu/util/flags.cc
@@ -578,12 +578,9 @@ vector<CommandLineFlagInfo> GetNonDefaultFlagsHelper() {
 string GetNonDefaultFlags() {
   ostringstream args;
   for (const auto& flag : GetNonDefaultFlagsHelper()) {
-    if (!args.str().empty()) {
-      args << '\n';
-    }
     // Redact the flags tagged as sensitive, if redaction is enabled.
     string flag_value = CheckFlagAndRedact(flag, EscapeMode::NONE);
-    args << "--" << flag.name << '=' << flag_value;
+    args << "--" << flag.name << '=' << flag_value << "\n";
   }
   return args.str();
 }

Reply via email to