public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-344] [Ada] Reuse generic string hash for invocation signatures
@ 2022-05-12 12:39 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-12 12:39 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d889e404c80685bf720fe2dd0f70a9baeb148791
commit r13-344-gd889e404c80685bf720fe2dd0f70a9baeb148791
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Thu Feb 3 19:55:34 2022 +0100
[Ada] Reuse generic string hash for invocation signatures
Use a generic string hash routine for hashing of invocation signatures.
The System.String_Hash unit was added to GNAT in 2009 and shouldn't
cause any bootstrap problems these days. To be safe, we don't use the
GNAT.String_Hash renaming, which was added later.
Cleanup related to a new restriction No_Uninitialized_Local_Scalars,
which will also rely on GNAT hash tables. Semantics is unaffected.
gcc/ada/
* ali.adb (Hash): Reuse GNAT.String_Hash.Hash and don't pollute
the Name_Id table.
Diff:
---
gcc/ada/ali.adb | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/gcc/ada/ali.adb b/gcc/ada/ali.adb
index 1c3b5cc725c..984e9ca7c5a 100644
--- a/gcc/ada/ali.adb
+++ b/gcc/ada/ali.adb
@@ -33,6 +33,7 @@ with Snames; use Snames;
with GNAT; use GNAT;
with GNAT.Dynamic_HTables; use GNAT.Dynamic_HTables;
+with System.String_Hash;
package body ALI is
@@ -578,20 +579,18 @@ package body ALI is
function Hash
(IS_Rec : Invocation_Signature_Record) return Bucket_Range_Type
is
+ function String_Hash is new System.String_Hash.Hash
+ (Char_Type => Character,
+ Key_Type => String,
+ Hash_Type => Bucket_Range_Type);
+
Buffer : Bounded_String (2052);
- IS_Nam : Name_Id;
begin
- -- The hash is obtained in the following manner:
- --
- -- * A String signature based on the scope, name, line number, column
- -- number, and locations, in the following format:
+ -- The hash is obtained from a signature based on the scope, name, line
+ -- number, column number, and locations, in the following format:
--
-- scope__name__line_column__locations
- --
- -- * The String is converted into a Name_Id
- --
- -- * The absolute value of the Name_Id is used as the hash
Append (Buffer, IS_Rec.Scope);
Append (Buffer, "__");
@@ -606,8 +605,7 @@ package body ALI is
Append (Buffer, IS_Rec.Locations);
end if;
- IS_Nam := Name_Find (Buffer);
- return Bucket_Range_Type (abs IS_Nam);
+ return String_Hash (To_String (Buffer));
end Hash;
--------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-12 12:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 12:39 [gcc r13-344] [Ada] Reuse generic string hash for invocation signatures Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).