From 8d95c5807351d1dfde5e81ecfd8a65524eec4f8b Mon Sep 17 00:00:00 2001 From: Emmanuel Briot Date: Wed, 20 Aug 2008 18:12:38 +0200 Subject: [PATCH] 2008-08-20 Emmanuel Briot * 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 | 27 +++++++++++++-------------- gcc/ada/g-catiio.ads | 11 +++++------ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/gcc/ada/g-catiio.adb b/gcc/ada/g-catiio.adb index f7b318e..0d0b9b8 100644 --- a/gcc/ada/g-catiio.adb +++ b/gcc/ada/g-catiio.adb @@ -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; -------------- diff --git a/gcc/ada/g-catiio.ads b/gcc/ada/g-catiio.ads index 34a3887..1f73c21 100644 --- a/gcc/ada/g-catiio.ads +++ b/gcc/ada/g-catiio.ads @@ -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 -- 2.7.4