From: Piotr Trojanek <troja...@adacore.com>

Use local constant to avoid repeated range checks (at least in the debug
builds), but also to make the code easier to read and consistent in style
with similar routines in the same package.

gcc/ada/ChangeLog:

        * urealp.adb (UR_Negate): Capture array element in a local constant.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/urealp.adb | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/urealp.adb b/gcc/ada/urealp.adb
index 3a9fddea60b..d5fb4f55be7 100644
--- a/gcc/ada/urealp.adb
+++ b/gcc/ada/urealp.adb
@@ -1237,12 +1237,13 @@ package body Urealp is
    ---------------
 
    function UR_Negate (Real : Ureal) return Ureal is
+      Val : constant Ureal_Entry := Ureals.Table (Real);
    begin
       return Store_Ureal
-               ((Num      => Ureals.Table (Real).Num,
-                 Den      => Ureals.Table (Real).Den,
-                 Rbase    => Ureals.Table (Real).Rbase,
-                 Negative => not Ureals.Table (Real).Negative));
+               ((Num      => Val.Num,
+                 Den      => Val.Den,
+                 Rbase    => Val.Rbase,
+                 Negative => not Val.Negative));
    end UR_Negate;
 
    ------------
-- 
2.43.0

Reply via email to