2008-08-20 Emmanuel Briot <briot@adacore.com>
authorEmmanuel Briot <briot@adacore.com>
Wed, 20 Aug 2008 16:12:38 +0000 (18:12 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 20 Aug 2008 16:12:38 +0000 (18:12 +0200)
* g-catiio.ads, g-catiio.adb:
(Value): Avoid an unnecessary system call to Clock in most cases.
This call is only needed when only the time is provided in the string,
and ignored in all other cases. This is more efficient.

From-SVN: r139333

gcc/ada/g-catiio.adb
gcc/ada/g-catiio.ads

index f7b318edbe31a8e7c6a5bb2b784aa1434d0ecddf..0d0b9b849fc23a0fda8a238896da5791c6f68989 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                     Copyright (C) 1999-2007, AdaCore                     --
+--                     Copyright (C) 1999-2008, AdaCore                     --
 --                                                                          --
 -- GNAT 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- --
@@ -560,13 +560,15 @@ package body GNAT.Calendar.Time_IO is
       D          : String (1 .. 21);
       D_Length   : constant Natural := Date'Length;
 
-      Year       : Year_Number;
-      Month      : Month_Number;
-      Day        : Day_Number;
-      Hour       : Hour_Number;
-      Minute     : Minute_Number;
-      Second     : Second_Number;
+      Year   : Year_Number;
+      Month  : Month_Number;
+      Day    : Day_Number;
+      Hour   : Hour_Number;
+      Minute : Minute_Number;
+      Second : Second_Number;
+
       Sub_Second : Second_Duration;
+      --  We ignore subseconds in this routine, so this is a throw away value
 
       procedure Extract_Date
         (Year       : out Year_Number;
@@ -770,9 +772,6 @@ package body GNAT.Calendar.Time_IO is
    --  Start of processing for Value
 
    begin
-      Split (Clock, Year, Month, Day, Hour, Minute, Second, Sub_Second);
-      Sub_Second := 0.0;
-
       --  Length checks
 
       if D_Length /= 8
@@ -792,12 +791,12 @@ package body GNAT.Calendar.Time_IO is
 
       D (1 .. D_Length) := Date;
 
-      if D_Length /= 8
-        or else D (3) /= ':'
-      then
+      if D_Length /= 8 or else D (3) /= ':' then
          Extract_Date (Year, Month, Day, Time_Start);
          Extract_Time (Time_Start, Hour, Minute, Second, Check_Space => True);
+
       else
+         Split (Clock, Year, Month, Day, Hour, Minute, Second, Sub_Second);
          Extract_Time (1, Hour, Minute, Second, Check_Space => False);
       end if;
 
@@ -813,7 +812,7 @@ package body GNAT.Calendar.Time_IO is
          raise Constraint_Error;
       end if;
 
-      return Time_Of (Year, Month, Day, Hour, Minute, Second, Sub_Second);
+      return Time_Of (Year, Month, Day, Hour, Minute, Second);
    end Value;
 
    --------------
index 34a38878c9fd33c0ff6b90f6748f11c62bef2cd2..1f73c2198ec30430af08dfb87566f67e222999b1 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                     Copyright (C) 1999-2007, AdaCore                     --
+--                     Copyright (C) 1999-2008, AdaCore                     --
 --                                                                          --
 -- GNAT 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- --
@@ -132,7 +132,7 @@ package GNAT.Calendar.Time_IO is
    --
    --  Trailing characters (in particular spaces) are not allowed
    --
-   --     yyyy*mm*dd
+   --     yyyy*mm*dd           - ISO format
    --     yy*mm*dd             - Year is assumed to be 20yy
    --     mm*dd*yyyy           - (US date format)
    --     dd*mmm*yyyy          - month spelled out
@@ -141,12 +141,11 @@ package GNAT.Calendar.Time_IO is
    --     mmm dd, yyyy         - month spelled out
    --     dd mmm yyyy          - month spelled out
    --
-   --  Constraint_Error is raised if the input string is malformatted or
+   --  Constraint_Error is raised if the input string is malformed (does not
+   --  conform to one of the above dates, or has an invalid time string), or
    --  the resulting time is not valid.
 
-   procedure Put_Time
-     (Date    : Ada.Calendar.Time;
-      Picture : Picture_String);
+   procedure Put_Time (Date : Ada.Calendar.Time; Picture : Picture_String);
    --  Put Date with format Picture. Raise Picture_Error if bad picture string
 
 private