]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/c-exp.y
Speed up psymbol reading by removing a copy
[thirdparty/binutils-gdb.git] / gdb / c-exp.y
index feab51a8e2cb356223cf9fea1043403973cabd38..f84691a62e7aff99838680cfa91263fe61a2b5b1 100644 (file)
@@ -1739,13 +1739,14 @@ oper:   OPERATOR NEW
 
                          c_print_type ($2, NULL, &buf, -1, 0,
                                        &type_print_raw_options);
+                         std::string name = std::move (buf.string ());
 
                          /* This also needs canonicalization.  */
-                         std::string canon
-                           = cp_canonicalize_string (buf.c_str ());
-                         if (canon.empty ())
-                           canon = std::move (buf.string ());
-                         $$ = operator_stoken ((" " + canon).c_str ());
+                         gdb::unique_xmalloc_ptr<char> canon
+                           = cp_canonicalize_string (name.c_str ());
+                         if (canon != nullptr)
+                           name = canon.get ();
+                         $$ = operator_stoken ((" " + name).c_str ());
                        }
        ;