diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2021-01-08 13:07:30 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-05-05 04:18:57 -0400 |
commit | 5e54a5cff4a7e3bd977c15849e431563eecd67ae (patch) | |
tree | 287b057d88efd81a355f45c1e9b07761ba9c21c3 | |
parent | af4e4d35f0b84d7c2f57a7b682a09116e9911142 (diff) | |
download | gcc-5e54a5cff4a7e3bd977c15849e431563eecd67ae.zip gcc-5e54a5cff4a7e3bd977c15849e431563eecd67ae.tar.gz gcc-5e54a5cff4a7e3bd977c15849e431563eecd67ae.tar.bz2 |
[Ada] Refactor repeated call to Next when pretty-printing if-expressions
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.
-rw-r--r-- | gcc/ada/pprint.adb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb index 161b62a..e3e26e8 100644 --- 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 => |