]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a-caldel-vms.adb, [...]: Minor code reorganization (use conditional expressions).
authorRobert Dewar <dewar@adacore.com>
Mon, 17 Aug 2009 10:09:55 +0000 (10:09 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 17 Aug 2009 10:09:55 +0000 (12:09 +0200)
2009-08-17  Robert Dewar  <dewar@adacore.com>

* a-caldel-vms.adb, a-calend-vms.adb, a-calfor.adb, a-cdlili.adb,
a-chahan.adb, a-cidlli.adb, a-coinve.adb, a-comlin.adb: Minor code
reorganization (use conditional expressions).

From-SVN: r150834

gcc/ada/ChangeLog
gcc/ada/a-caldel-vms.adb
gcc/ada/a-calend-vms.adb
gcc/ada/a-calfor.adb
gcc/ada/a-cdlili.adb
gcc/ada/a-chahan.adb
gcc/ada/a-cidlli.adb
gcc/ada/a-coinve.adb
gcc/ada/a-comlin.adb

index 5a17cdbe2bee69e7e16909a11fa9d6c1ae2e46e2..2107917f803ebcec3cbdcaaabfe30fd965e17155 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-17  Robert Dewar  <dewar@adacore.com>
+
+       * a-caldel-vms.adb, a-calend-vms.adb, a-calfor.adb, a-cdlili.adb,
+       a-chahan.adb, a-cidlli.adb, a-coinve.adb, a-comlin.adb: Minor code
+       reorganization (use conditional expressions).
+
 2009-08-17  Robert Dewar  <dewar@adacore.com>
 
        * make.adb: Add ??? comment
index 8b7715744d6a492a6d76b0ca0093b7695a493eed..128918a9ac6248c6750efad66f9cbf2100a2c786 100644 (file)
@@ -7,7 +7,7 @@
 --                                  B o d y                                 --
 --                                                                          --
 --             Copyright (C) 1991-1994, Florida State University            --
---                     Copyright (C) 1995-2008, AdaCore                     --
+--                     Copyright (C) 1995-2009, AdaCore                     --
 --                                                                          --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -79,15 +79,10 @@ package body Ada.Calendar.Delays is
       --  A value distant enough to emulate "end of time" but which does not
       --  cause overflow.
 
-      Safe_T : Time;
+      Safe_T : constant Time :=
+                 (if T > Safe_Ada_High then Safe_Ada_High else T);
 
    begin
-      if T > Safe_Ada_High then
-         Safe_T := Safe_Ada_High;
-      else
-         Safe_T := T;
-      end if;
-
       return OSP.To_Duration (OSP.OS_Time (Safe_T), OSP.Absolute_Calendar);
    end To_Duration;
 
index 374ea715ff62700c51361fcaa87b5ab62738b95f..3daf4e0c185cc010b78835c1427add61dee2b396 100644 (file)
@@ -921,11 +921,7 @@ package body Ada.Calendar is
 
          --  Step 3: Handle leap second occurrences
 
-         if Leap_Sec then
-            tm_sec := 60;
-         else
-            tm_sec := Second;
-         end if;
+         tm_Sec := (if Leap_Sec then 60 else Second);
       end To_Struct_Tm;
 
       ------------------
@@ -1195,11 +1191,10 @@ package body Ada.Calendar is
             else
                --  Sub second extraction
 
-               if Day_Secs > 0.0 then
-                  Int_Day_Secs := Integer (Day_Secs - 0.5);
-               else
-                  Int_Day_Secs := Integer (Day_Secs);
-               end if;
+               Int_Day_Secs :=
+                 (if Day_Secs > 0.0
+                  then Integer (Day_Secs - 0.5)
+                  else Integer (Day_Secs));
 
                H  := Int_Day_Secs / 3_600;
                Mi := (Int_Day_Secs / 60) mod 60;
index 10e9617022c4eea154a961dd199e908392cd260c..b8e6222475dad46e22def19c2110eea25b4914b7 100644 (file)
@@ -156,17 +156,8 @@ package body Ada.Calendar.Formatting is
       --  Determine the two slice bounds for the result string depending on
       --  whether the input is negative and whether fractions are requested.
 
-      if Elapsed_Time < 0.0 then
-         Low := 1;
-      else
-         Low := 2;
-      end if;
-
-      if Include_Time_Fraction then
-         High := 12;
-      else
-         High := 9;
-      end if;
+      Low  := (if Elapsed_Time < 0.0 then 1 else 2);
+      High := (if Include_Time_Fraction then 12 else 9);
 
       --  Prevent rounding when converting to natural
 
@@ -457,11 +448,7 @@ package body Ada.Calendar.Formatting is
          raise Constraint_Error;
       end if;
 
-      if Seconds = 0.0 then
-         Secs := 0;
-      else
-         Secs := Natural (Seconds - 0.5);
-      end if;
+      Secs := (if Seconds = 0.0 then 0 else Natural (Seconds - 0.5));
 
       Sub_Second := Second_Duration (Seconds - Day_Duration (Secs));
       Hour       := Hour_Number (Secs / 3_600);
index c0fae213a4fcb97564e5b7877b8170d639d55117..f9d7db832da1d941c4ceb0df58f5daa17fe6732f 100644 (file)
@@ -561,15 +561,9 @@ package body Ada.Containers.Doubly_Linked_Lists is
          ----------
 
          procedure Sort (Front, Back : Node_Access) is
-            Pivot : Node_Access;
-
+            Pivot : constant Node_Access :=
+                      (if Front = null then Container.First else Front.Next);
          begin
-            if Front = null then
-               Pivot := Container.First;
-            else
-               Pivot := Front.Next;
-            end if;
-
             if Pivot /= Back then
                Partition (Pivot, Back);
                Sort (Front, Pivot);
index e6a9361785752359528cbb29858f13aca51db857..61419b090ee87c02ab65fd2c55cb85f59d0e8dbc 100644 (file)
@@ -457,11 +457,7 @@ package body Ada.Characters.Handling is
       Substitute : ISO_646 := ' ') return ISO_646
    is
    begin
-      if Item in ISO_646 then
-         return Item;
-      else
-         return Substitute;
-      end if;
+      return (if Item in ISO_646 then Item else Substitute);
    end To_ISO_646;
 
    function To_ISO_646
@@ -472,11 +468,8 @@ package body Ada.Characters.Handling is
 
    begin
       for J in Item'Range loop
-         if Item (J) in ISO_646 then
-            Result (J - (Item'First - 1)) := Item (J);
-         else
-            Result (J - (Item'First - 1)) := Substitute;
-         end if;
+         Result (J - (Item'First - 1)) :=
+           (if Item (J) in ISO_646 then Item (J) else Substitute);
       end loop;
 
       return Result;
index 510b7707b09ad75e83e8598d7617c10ef9729e97..0d01502e05dcdfb8503261df04304ab42a232129 100644 (file)
@@ -605,15 +605,9 @@ package body Ada.Containers.Indefinite_Doubly_Linked_Lists is
          ----------
 
          procedure Sort (Front, Back : Node_Access) is
-            Pivot : Node_Access;
-
+            Pivot : constant Node_Access :=
+                      (if Front = null then Container.First else Front.Next);
          begin
-            if Front = null then
-               Pivot := Container.First;
-            else
-               Pivot := Front.Next;
-            end if;
-
             if Pivot /= Back then
                Partition (Pivot, Back);
                Sort (Front, Pivot);
index ffa2d1b4e2b6e4e590c45f3badcfcf202e75928b..9169e086ebdfa2b050e76d08651116f183c57970 100644 (file)
@@ -1171,7 +1171,6 @@ package body Ada.Containers.Indefinite_Vectors is
            and then Index_Type'Last >= 0
          then
             CC := UInt (Index_Type'Last) + UInt (-Index_Type'First) + 1;
-
          else
             CC := UInt (Int (Index_Type'Last) - First + 1);
          end if;
@@ -1610,7 +1609,6 @@ package body Ada.Containers.Indefinite_Vectors is
            and then Index_Type'Last >= 0
          then
             CC := UInt (Index_Type'Last) + UInt (-Index_Type'First) + 1;
-
          else
             CC := UInt (Int (Index_Type'Last) - First + 1);
          end if;
@@ -2283,15 +2281,9 @@ package body Ada.Containers.Indefinite_Vectors is
       Item      : Element_Type;
       Index     : Index_Type := Index_Type'Last) return Extended_Index
    is
-      Last : Index_Type'Base;
-
+      Last : constant Index_Type'Base :=
+               (if Index > Container.Last then Container.Last else Index);
    begin
-      if Index > Container.Last then
-         Last := Container.Last;
-      else
-         Last := Index;
-      end if;
-
       for Indx in reverse Index_Type'First .. Last loop
          if Container.Elements.EA (Indx) /= null
            and then Container.Elements.EA (Indx).all = Item
index 2b6c32e104f320e23603f23f9064c615741cca26..b29693638d6e37cbe1d957b0f08780f18cafe066 100644 (file)
@@ -29,7 +29,9 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System;                 use System;
+pragma Compiler_Unit;
+
+with System; use System;
 
 package body Ada.Command_Line is
 
@@ -71,7 +73,6 @@ package body Ada.Command_Line is
 
       declare
          Arg : aliased String (1 .. Len_Arg (Num));
-
       begin
          Fill_Arg (Arg'Address, Num);
          return Arg;