gdb: move cmd_list_element::prefixname to cli/cli-decode.c
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 17 May 2021 18:00:48 +0000 (14:00 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 17 May 2021 18:00:48 +0000 (14:00 -0400)
I don't think this method really benefits from being implemented in the
header file, especially because it's recursive, it can't be inlined.
Move it to the source file, so it's no re-compiled by every CU
including cli/cli-decode.h.

I also noticed this method could be const, make it so.

gdb/ChangeLog:

* cli/cli-decode.h (prefixname): Make const, move implementation
to cli/cli-decode.c.
* cli/cli-decode.c (cmd_list_element::prefixname): New.

Change-Id: I1597cace98d9a4ba71f51f1f495e73cc07b5dcf3

gdb/ChangeLog
gdb/cli/cli-decode.c
gdb/cli/cli-decode.h

index 81e9dd5a29cd65acb149cd26fba23ff2b6de1138..c9f5181a7e1a9285b52df2cedffa5355c349b23d 100644 (file)
@@ -1,3 +1,9 @@
+2021-05-17  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * cli/cli-decode.h (prefixname): Make const, move implementation
+       to cli/cli-decode.c.
+       * cli/cli-decode.c (cmd_list_element::prefixname): New.
+
 2021-05-16  Weimin Pan  <weimin.pan@oracle.com>
 
        * ctfread.c (new_symbol): Set function address.
index 32edb526c8755fd7de7e7561338af27457262f6e..a3b153f06e4877b2fe38be1e2ddab05b423e8474 100644 (file)
@@ -160,6 +160,23 @@ set_cmd_completer_handle_brkchars (struct cmd_list_element *cmd,
   cmd->completer_handle_brkchars = func;
 }
 
+std::string
+cmd_list_element::prefixname () const
+{
+  if (this->prefixlist == nullptr)
+    /* Not a prefix command.  */
+    return "";
+
+  std::string prefixname;
+  if (this->prefix != nullptr)
+    prefixname = this->prefix->prefixname ();
+
+  prefixname += this->name;
+  prefixname += " ";
+
+  return prefixname;
+}
+
 /* Add element named NAME.
    Space for NAME and DOC must be allocated by the caller.
    CLASS is the top level category into which commands are broken down
index da6013a6cc522542ebb7a2399d1262344ca7fa89..e6d6f32cbfa923b27fc39a480567db32f148b9e2 100644 (file)
@@ -76,20 +76,8 @@ struct cmd_list_element
      space.  It is used before the word "command" in describing the
      commands reached through this prefix.
 
-     For non-prefix commands, an empty string is returned.  */
-  std::string prefixname ()
-  {
-    if (prefixlist == nullptr)
-      /* Not a prefix command.  */
-      return "";
-
-    std::string prefixname;
-    if (prefix != nullptr)
-      prefixname = prefix->prefixname ();
-    prefixname += name;
-    prefixname += " ";
-    return prefixname;
-  }
+     For non-prefix commands, return an empty string.  */
+  std::string prefixname () const;
 
   /* Points to next command in this list.  */
   struct cmd_list_element *next = nullptr;
This page took 0.028907 seconds and 4 git commands to generate.