Browse Source

cmCursesLongMessageForm: avoid unnecessary string allocation

The addition makes a temporary string and then drops it after adding it
to `this->Messages`. Instead, just incrementally append.
Ben Boeckel 5 years ago
parent
commit
603a532b58
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Source/CursesDialog/cmCursesLongMessageForm.cxx

+ 2 - 1
Source/CursesDialog/cmCursesLongMessageForm.cxx

@@ -41,7 +41,8 @@ void cmCursesLongMessageForm::UpdateContent(std::string const& output,
   this->Title = title;
 
   if (!output.empty() && this->Messages.size() < MAX_CONTENT_SIZE) {
-    this->Messages.append("\n" + output);
+    this->Messages.push_back('\n');
+    this->Messages.append(output);
     form_driver(this->Form, REQ_NEW_LINE);
     this->DrawMessage(output.c_str());
   }