From: Piotr Trojanek Date: Sun, 17 May 2026 11:39:12 +0000 (+0200) Subject: ada: Simplify construction of internal string from characters X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=ae59b39ffb2ee07bf536ca2d45beab2199615644;p=thirdparty%2Fgcc.git ada: Simplify construction of internal string from characters Reuse a variant of Store_String_Char routine that accepts a Character parameter and internally calls Get_Char_Code. Code cleanup. gcc/ada/ChangeLog: * exp_attr.adb (Expand_N_Attribute_Reference): Store chars without converting the actual parameters. * exp_ch11.adb (Null_String): Likewise. * exp_disp.adb (Make_DT): Likewise. * exp_util.adb (Fully_Qualified_Name_String): Likewise. * sem_attr.adb (Analyze_Attribute): Likewise. * sem_dist.adb (Full_Qualified_Name): Likewise. * sem_prag.adb (Process_Interface_Name, Set_Encoded_Interface_Name): Likewise. * stringt.adb (Store_String_Chars): Likewise. --- diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index d1b9510ce12..e5bd95d5a52 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -3391,7 +3391,7 @@ package body Exp_Attr is if Name_Buffer (J) = '.' then Store_String_Chars ("__"); else - Store_String_Char (Get_Char_Code (Name_Buffer (J))); + Store_String_Char (Name_Buffer (J)); end if; end loop; diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb index 2210437cfe9..ff312ec7700 100644 --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp_ch11.adb @@ -1087,7 +1087,7 @@ package body Exp_Ch11 is function Null_String return String_Id is begin Start_String; - Store_String_Char (Get_Char_Code (ASCII.NUL)); + Store_String_Char (ASCII.NUL); return End_String; end Null_String; diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index 13fc8158e78..93bc7aef653 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -5345,7 +5345,7 @@ package body Exp_Disp is New_Val := Old_Val; else Start_String (Old_Val); - Store_String_Char (Get_Char_Code (ASCII.NUL)); + Store_String_Char (ASCII.NUL); New_Val := End_String; end if; diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 172039b3a71..842ed5998a3 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -7401,7 +7401,7 @@ package body Exp_Util is if Present (Scope (Scope (Ent))) then Internal_Full_Qualified_Name (Scope (Ent)); - Store_String_Char (Get_Char_Code ('.')); + Store_String_Char ('.'); end if; -- Every entity should have a name except some expanded blocks @@ -7426,7 +7426,7 @@ package body Exp_Util is Internal_Full_Qualified_Name (E); if Append_NUL then - Store_String_Char (Get_Char_Code (ASCII.NUL)); + Store_String_Char (ASCII.NUL); end if; return End_String; diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 171dce197ea..dc6104602a3 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -7400,9 +7400,7 @@ package body Sem_Attr is -- Copy all characters in Full_Name - for J in 1 .. String_Length (Full_Name) loop - Store_String_Char (Get_String_Char (Full_Name, Pos (J))); - end loop; + Store_String_Chars (Full_Name); -- Compute CRC and convert it to string one character at a time, so -- as not to use Image within the compiler. @@ -7501,14 +7499,14 @@ package body Sem_Attr is Start_String; if Negative then - Store_String_Char (Get_Char_Code ('-')); + Store_String_Char ('-'); end if; S := Sloc (Expr); Src := Source_Text (Get_Source_File_Index (S)); while Src (S) /= ';' and then Src (S) /= ' ' loop - Store_String_Char (Get_Char_Code (Src (S))); + Store_String_Char (Src (S)); S := S + 1; end loop; diff --git a/gcc/ada/sem_dist.adb b/gcc/ada/sem_dist.adb index 05a6777dc2f..c1efc696e8d 100644 --- a/gcc/ada/sem_dist.adb +++ b/gcc/ada/sem_dist.adb @@ -188,7 +188,7 @@ package body Sem_Dist is if Parent_Name /= No_String then Start_String (Parent_Name); - Store_String_Char (Get_Char_Code ('.')); + Store_String_Char ('.'); else Start_String; end if; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 18c3315bcee..24d61afd7e1 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -11540,7 +11540,7 @@ package body Sem_Prag is else Start_String; - Store_String_Char (Get_Char_Code ('*')); + Store_String_Char ('*'); String_Val := Strval (Expr_Value_S (Link_Nam)); Store_String_Chars (String_Val); Link_Nam := @@ -35827,15 +35827,11 @@ package body Sem_Prag is procedure Encode is begin - Store_String_Char (Get_Char_Code ('_')); - Store_String_Char - (Get_Char_Code (Hex (Integer (CC / 2 ** 12)))); - Store_String_Char - (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#)))); - Store_String_Char - (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#)))); - Store_String_Char - (Get_Char_Code (Hex (Integer (CC and 16#0F#)))); + Store_String_Char ('_'); + Store_String_Char (Hex (Integer (CC / 2 ** 12))); + Store_String_Char (Hex (Integer (CC / 2 ** 8 and 16#0F#))); + Store_String_Char (Hex (Integer (CC / 2 ** 4 and 16#0F#))); + Store_String_Char (Hex (Integer (CC and 16#0F#))); end Encode; -- Start of processing for Set_Encoded_Interface_Name diff --git a/gcc/ada/stringt.adb b/gcc/ada/stringt.adb index d9853140c7b..6a9c448b8cc 100644 --- a/gcc/ada/stringt.adb +++ b/gcc/ada/stringt.adb @@ -214,7 +214,7 @@ package body Stringt is procedure Store_String_Chars (S : String) is begin for J in S'First .. S'Last loop - Store_String_Char (Get_Char_Code (S (J))); + Store_String_Char (S (J)); end loop; end Store_String_Chars;