public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Remove some "goto"s from parse.c
@ 2023-04-25 17:57 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-04-25 17:57 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fc53c8e02183b61a9df0224de1d7016fb52960ba

commit fc53c8e02183b61a9df0224de1d7016fb52960ba
Author: Tom Tromey <tromey@adacore.com>
Date:   Mon Apr 24 13:03:03 2023 -0600

    Remove some "goto"s from parse.c
    
    parser_state::push_dollar has some unnecessary "goto"s.  Replacing
    them cleans up the code.  Regression tested on x86-64 Fedora 36.
    
    Approved-By: Simon Marchi <simon.marchi@efficios.com>

Diff:
---
 gdb/parse.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/gdb/parse.c b/gdb/parse.c
index 0588c0618c6..85a6caf14ba 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -268,7 +268,8 @@ parser_state::push_dollar (struct stoken str)
     {
       /* Just dollars (one or two).  */
       i = -negate;
-      goto handle_last;
+      push_new<expr::last_operation> (i);
+      return;
     }
   /* Is the rest of the token digits?  */
   for (; i < str.length; i++)
@@ -279,7 +280,8 @@ parser_state::push_dollar (struct stoken str)
       i = atoi (str.ptr + 1 + negate);
       if (negate)
 	i = -i;
-      goto handle_last;
+      push_new<expr::last_operation> (i);
+      return;
     }
 
   /* Handle tokens that refer to machine registers:
@@ -287,7 +289,14 @@ parser_state::push_dollar (struct stoken str)
   i = user_reg_map_name_to_regnum (gdbarch (),
 				   str.ptr + 1, str.length - 1);
   if (i >= 0)
-    goto handle_register;
+    {
+      str.length--;
+      str.ptr++;
+      push_new<expr::register_operation> (copy_name (str));
+      block_tracker->update (expression_context_block,
+			     INNERMOST_BLOCK_FOR_REGISTERS);
+      return;
+    }
 
   /* Any names starting with $ are probably debugger internal variables.  */
 
@@ -319,17 +328,6 @@ parser_state::push_dollar (struct stoken str)
 
   push_new<expr::internalvar_operation>
     (create_internalvar (copy.c_str () + 1));
-  return;
-handle_last:
-  push_new<expr::last_operation> (i);
-  return;
-handle_register:
-  str.length--;
-  str.ptr++;
-  push_new<expr::register_operation> (copy_name (str));
-  block_tracker->update (expression_context_block,
-			 INNERMOST_BLOCK_FOR_REGISTERS);
-  return;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-25 17:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-25 17:57 [binutils-gdb] Remove some "goto"s from parse.c Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).