]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Simplify uses of the global name buffer
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 4 Dec 2024 15:42:29 +0000 (16:42 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 3 Jan 2025 15:39:13 +0000 (16:39 +0100)
Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_dist.adb (Assign_Subprogram_Identifier,
Reserve_NamingContext_Methods): Simplify.
* osint.adb (Append_Suffix_To_File_Name, Find_File, Get_Directory,
Object_File_Name, Strip_Directory): Likewise.

gcc/ada/exp_dist.adb
gcc/ada/osint.adb

index fcfeba0e1a6757d1e80e230a8cae49b555364673..e8f9b68baf350df6dbb5ea519b2807591155d898 100644 (file)
@@ -2089,8 +2089,7 @@ package body Exp_Dist is
       --  disambiguated within their own scope.
 
       if Overload_Order > 1 then
-         Name_Buffer (Name_Len + 1 .. Name_Len + 2) := "__";
-         Name_Len := Name_Len + 2;
+         Add_Str_To_Name_Buffer ("__");
          Add_Nat_To_Name_Buffer (Overload_Order);
       end if;
 
@@ -11188,11 +11187,8 @@ package body Exp_Dist is
       -----------------------------------
 
       procedure Reserve_NamingContext_Methods is
-         Str_Resolve : constant String := "resolve";
       begin
-         Name_Buffer (1 .. Str_Resolve'Length) := Str_Resolve;
-         Name_Len := Str_Resolve'Length;
-         Overload_Counter_Table.Set (Name_Find, 1);
+         Overload_Counter_Table.Set (Name_Find ("resolve"), 1);
       end Reserve_NamingContext_Methods;
 
       -----------------------
index 645cb630b13b0b85f0b1dd3c52991c4903ba7de8..364c069a099ff23345cc2346d7a56b44ae772d59 100644 (file)
@@ -658,8 +658,7 @@ package body Osint is
    is
    begin
       Get_Name_String (Name);
-      Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
-      Name_Len := Name_Len + Suffix'Length;
+      Add_Str_To_Name_Buffer (Suffix);
       return Name_Find;
    end Append_Suffix_To_File_Name;
 
@@ -1225,12 +1224,8 @@ package body Osint is
                   declare
                      Full_Path : constant String :=
                                    Normalize_Pathname (Get_Name_String (N));
-                     Full_Size : constant Natural := Full_Path'Length;
-
                   begin
-                     Name_Buffer (1 .. Full_Size) := Full_Path;
-                     Name_Len := Full_Size;
-                     Found    := Name_Find;
+                     Found := Name_Find (Full_Path);
                   end;
                end if;
 
@@ -1446,9 +1441,7 @@ package body Osint is
          end if;
       end loop;
 
-      Name_Len := Hostparm.Normalized_CWD'Length;
-      Name_Buffer (1 .. Name_Len) := Hostparm.Normalized_CWD;
-      return Name_Find;
+      return Name_Find (Hostparm.Normalized_CWD);
    end Get_Directory;
 
    ------------------------------
@@ -2182,10 +2175,7 @@ package body Osint is
       Get_Name_String (N);
       Name_Len := Name_Len - ALI_Suffix'Length - 1;
 
-      for J in Target_Object_Suffix'Range loop
-         Name_Len := Name_Len + 1;
-         Name_Buffer (Name_Len) := Target_Object_Suffix (J);
-      end loop;
+      Add_Str_To_Name_Buffer (Target_Object_Suffix);
 
       return Name_Enter;
    end Object_File_Name;
@@ -2935,9 +2925,7 @@ package body Osint is
 
             --  Return part of Name that follows this last directory separator
 
-            Name_Buffer (1 .. Name_Len - J) := Name_Buffer (J + 1 .. Name_Len);
-            Name_Len := Name_Len - J;
-            return Name_Find;
+            return Name_Find (Name_Buffer (J + 1 .. Name_Len));
          end if;
       end loop;