public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Use Add_Char_To_Name_Buffer for 1-character strings
@ 2022-01-05 11:33 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-01-05 11:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

Adding a single character to name buffer should be (marginally) more
efficient with Add_Char_To_Name_Buffer and not Add_Str_To_Name_Buffer.
Even if not more efficient, it should be still more readable.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_dbug.adb, sem_dim.adb: Replace Add_Str_To_Name_Buffer with
	Add_Char_To_Name_Buffer.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2046 bytes --]

diff --git a/gcc/ada/exp_dbug.adb b/gcc/ada/exp_dbug.adb
--- a/gcc/ada/exp_dbug.adb
+++ b/gcc/ada/exp_dbug.adb
@@ -172,7 +172,7 @@ package body Exp_Dbug is
    procedure Add_Real_To_Buffer (U : Ureal) is
    begin
       Add_Uint_To_Buffer (Norm_Num (U));
-      Add_Str_To_Name_Buffer ("_");
+      Add_Char_To_Name_Buffer ('_');
       Add_Uint_To_Buffer (Norm_Den (U));
    end Add_Real_To_Buffer;
 
@@ -671,7 +671,7 @@ package body Exp_Dbug is
          Add_Real_To_Buffer (Delta_Value (E));
 
          if Small_Value (E) /= Delta_Value (E) then
-            Add_Str_To_Name_Buffer ("_");
+            Add_Char_To_Name_Buffer ('_');
             Add_Real_To_Buffer (Small_Value (E));
          end if;
 
@@ -710,7 +710,7 @@ package body Exp_Dbug is
 
             if Lo_Encode or Hi_Encode then
                if Biased then
-                  Add_Str_To_Name_Buffer ("_");
+                  Add_Char_To_Name_Buffer ('_');
                else
                   if Lo_Encode then
                      if Hi_Encode then
@@ -1535,7 +1535,7 @@ package body Exp_Dbug is
 
                begin
                   Set_Entity_Name (Var);
-                  Add_Str_To_Name_Buffer ("L");
+                  Add_Char_To_Name_Buffer ('L');
                   Set_Chars (Var, Name_Enter);
                end;
 
@@ -1544,7 +1544,7 @@ package body Exp_Dbug is
               and then Ekind (Scope (Homonym (Ent))) = E_Block
             then
                Set_Entity_Name (Ent);
-               Add_Str_To_Name_Buffer ("B");
+               Add_Char_To_Name_Buffer ('B');
                Set_Chars (Ent, Name_Enter);
             end if;
          end if;


diff --git a/gcc/ada/sem_dim.adb b/gcc/ada/sem_dim.adb
--- a/gcc/ada/sem_dim.adb
+++ b/gcc/ada/sem_dim.adb
@@ -2759,7 +2759,7 @@ package body Sem_Dim is
 
       --  Insert a blank between the literal and the symbol
 
-      Add_Str_To_Name_Buffer (" ");
+      Add_Char_To_Name_Buffer (' ');
       Append (Global_Name_Buffer, Symbol_Of (Typ));
 
       Error_Msg_Name_1 := Name_Find;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-05 11:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 11:33 [Ada] Use Add_Char_To_Name_Buffer for 1-character strings 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).