diff options
author | Bob Duff <duff@adacore.com> | 2017-04-27 13:43:49 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-04-27 15:43:49 +0200 |
commit | a2168462958f03ca5b060ad49e217a3e262750d0 (patch) | |
tree | 9bc9c64f1c0dab1d83d0e57fd7a8eb3a7fdab89b /gcc/ada/namet.adb | |
parent | f8a36447dbdf5baafe85f953c261ec35f149dfb7 (diff) | |
download | gcc-a2168462958f03ca5b060ad49e217a3e262750d0.zip gcc-a2168462958f03ca5b060ad49e217a3e262750d0.tar.gz gcc-a2168462958f03ca5b060ad49e217a3e262750d0.tar.bz2 |
sinput.adb: Minor code cleanup.
2017-04-27 Bob Duff <duff@adacore.com>
* sinput.adb: Minor code cleanup.
* namet.adb (Append): Create faster versions of
Append(String) and Append(Name_Id) by using slice assignment
instead of loops.
* sem_util.adb (In_Instance): Speed this up by removing
unnecessary tests; Is_Generic_Instance is defined for all
entities.
* sem_util.ads, sem_util.adb (In_Parameter_Specification):
Remove unused function.
* alloc.ads (Nodes_Initial): Use a much larger value, because
the compiler was spending a lot of time copying the nodes table
when it grows. This number was chosen in 1996, so is rather out
of date with current memory sizes. Anyway, it's virtual memory.
Get rid of Orig_Nodes_...; use Node_... instead.
* atree.adb (Lock): Do not release the Nodes tables; it's a
waste of time.
Orig_Nodes_ ==> Nodes_
* nlists.adb: Orig_Nodes_ ==> Nodes_
* g-table.adb: Remove unused "with" clause.
* g-table.ads, table.ads: Remove Big_Table_Type, which should
not be used by clients.
* g-dyntab.adb (Last_Allocated): New function
to encapsulate T.P.Last_Allocated, which I'm thinking of changing.
From-SVN: r247335
Diffstat (limited to 'gcc/ada/namet.adb')
-rw-r--r-- | gcc/ada/namet.adb | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/gcc/ada/namet.adb b/gcc/ada/namet.adb index b87dd91..4e6a69a 100644 --- a/gcc/ada/namet.adb +++ b/gcc/ada/namet.adb @@ -116,14 +116,15 @@ package body Namet is procedure Append (Buf : in out Bounded_String; C : Character) is begin - if Buf.Length >= Buf.Chars'Last then + Buf.Length := Buf.Length + 1; + + if Buf.Length > Buf.Chars'Last then Write_Str ("Name buffer overflow; Max_Length = "); Write_Int (Int (Buf.Max_Length)); Write_Line (""); raise Program_Error; end if; - Buf.Length := Buf.Length + 1; Buf.Chars (Buf.Length) := C; end Append; @@ -137,10 +138,20 @@ package body Namet is end Append; procedure Append (Buf : in out Bounded_String; S : String) is + First : constant Natural := Buf.Length + 1; begin - for J in S'Range loop - Append (Buf, S (J)); - end loop; + Buf.Length := Buf.Length + S'Length; + + if Buf.Length > Buf.Chars'Last then + Write_Str ("Name buffer overflow; Max_Length = "); + Write_Int (Int (Buf.Max_Length)); + Write_Line (""); + raise Program_Error; + end if; + + Buf.Chars (First .. Buf.Length) := S; + -- A loop calling Append(Character) would be cleaner, but this slice + -- assignment is substantially faster. end Append; procedure Append (Buf : in out Bounded_String; Buf2 : Bounded_String) is @@ -150,12 +161,12 @@ package body Namet is procedure Append (Buf : in out Bounded_String; Id : Name_Id) is pragma Assert (Id in Name_Entries.First .. Name_Entries.Last); - S : constant Int := Name_Entries.Table (Id).Name_Chars_Index; - + Index : constant Int := Name_Entries.Table (Id).Name_Chars_Index; + Len : constant Short := Name_Entries.Table (Id).Name_Len; + Chars : Name_Chars.Table_Type renames + Name_Chars.Table (Index + 1 .. Index + Int (Len)); begin - for J in 1 .. Natural (Name_Entries.Table (Id).Name_Len) loop - Append (Buf, Name_Chars.Table (S + Int (J))); - end loop; + Append (Buf, String (Chars)); end Append; -------------------- |