* [Ada] Refactor repeated call to Next when pretty-printing if-expressions
@ 2021-05-05 8:20 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-05 8:20 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 303 bytes --]
Code cleanup (and minuscule performance improvement); semantics is
unaffected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* pprint.adb (Expr_Name): Introduce local constants to make the
code more readable and avoid repeated calls to Next to reach the
ELSE part of an if-expression.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 949 bytes --]
diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb
--- a/gcc/ada/pprint.adb
+++ b/gcc/ada/pprint.adb
@@ -410,12 +410,14 @@ package body Pprint is
when N_If_Expression =>
declare
- N : constant Node_Id := First (Expressions (Expr));
+ Cond_Expr : constant Node_Id := First (Expressions (Expr));
+ Then_Expr : constant Node_Id := Next (Cond_Expr);
+ Else_Expr : constant Node_Id := Next (Then_Expr);
begin
return
- "if " & Expr_Name (N) & " then "
- & Expr_Name (Next (N)) & " else "
- & Expr_Name (Next (Next (N)));
+ "if " & Expr_Name (Cond_Expr) & " then "
+ & Expr_Name (Then_Expr) & " else "
+ & Expr_Name (Else_Expr);
end;
when N_Qualified_Expression =>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-05 8:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 8:20 [Ada] Refactor repeated call to Next when pretty-printing if-expressions Pierre-Marie de Rodat
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).