diff mbox series

[COMMITTED,17/30] ada: Remove streaming facilities from generics for formal containers

Message ID 20240610090747.1557638-17-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/30] ada: Refactor checks for Refined_Global in generic instances | expand

Commit Message

Marc Poulhiès June 10, 2024, 9:07 a.m. UTC
From: Yannick Moy <moy@adacore.com>

The dependency on Ada.Streams is problematic for light runtimes.
As these streaming facilities are in fact not used in formal containers,
remove the corresponding dead code.

gcc/ada/

	* libgnat/a-chtgfo.adb (Generic_Read, Generic_Write): Remove.
	* libgnat/a-chtgfo.ads: Same. Remove dependency on Ada.Streams.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/a-chtgfo.adb | 68 ------------------------------------
 gcc/ada/libgnat/a-chtgfo.ads | 24 -------------
 2 files changed, 92 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/libgnat/a-chtgfo.adb b/gcc/ada/libgnat/a-chtgfo.adb
index c3fff336e9d..df7b554c050 100644
--- a/gcc/ada/libgnat/a-chtgfo.adb
+++ b/gcc/ada/libgnat/a-chtgfo.adb
@@ -359,74 +359,6 @@  package body Ada.Containers.Hash_Tables.Generic_Formal_Operations is
       end loop;
    end Generic_Iteration;
 
-   ------------------
-   -- Generic_Read --
-   ------------------
-
-   procedure Generic_Read
-     (Stream : not null access Root_Stream_Type'Class;
-      HT     : out Hash_Table_Type)
-   is
-      N : Count_Type'Base;
-
-   begin
-      Clear (HT);
-
-      Count_Type'Base'Read (Stream, N);
-
-      if Checks and then N < 0 then
-         raise Program_Error with "stream appears to be corrupt";
-      end if;
-
-      if N = 0 then
-         return;
-      end if;
-
-      if Checks and then N > HT.Capacity then
-         raise Capacity_Error with "too many elements in stream";
-      end if;
-
-      for J in 1 .. N loop
-         declare
-            Node : constant Count_Type := New_Node (Stream);
-            Indx : constant Hash_Type := Index (HT, HT.Nodes (Node));
-            B    : Count_Type renames HT.Buckets (Indx);
-         begin
-            Set_Next (HT.Nodes (Node), Next => B);
-            B := Node;
-         end;
-
-         HT.Length := HT.Length + 1;
-      end loop;
-   end Generic_Read;
-
-   -------------------
-   -- Generic_Write --
-   -------------------
-
-   procedure Generic_Write
-     (Stream : not null access Root_Stream_Type'Class;
-      HT     : Hash_Table_Type)
-   is
-      procedure Write (Node : Count_Type);
-      pragma Inline (Write);
-
-      procedure Write is new Generic_Iteration (Write);
-
-      -----------
-      -- Write --
-      -----------
-
-      procedure Write (Node : Count_Type) is
-      begin
-         Write (Stream, HT.Nodes (Node));
-      end Write;
-
-   begin
-      Count_Type'Base'Write (Stream, HT.Length);
-      Write (HT);
-   end Generic_Write;
-
    -----------
    -- Index --
    -----------
diff --git a/gcc/ada/libgnat/a-chtgfo.ads b/gcc/ada/libgnat/a-chtgfo.ads
index 76633d8da05..f4471bec3d2 100644
--- a/gcc/ada/libgnat/a-chtgfo.ads
+++ b/gcc/ada/libgnat/a-chtgfo.ads
@@ -30,8 +30,6 @@ 
 --  Hash_Table_Type is used to implement hashed containers. This package
 --  declares hash-table operations that do not depend on keys.
 
-with Ada.Streams;
-
 generic
    with package HT_Types is
      new Generic_Formal_Hash_Table_Types (<>);
@@ -113,26 +111,4 @@  package Ada.Containers.Hash_Tables.Generic_Formal_Operations is
    procedure Generic_Iteration (HT : Hash_Table_Type);
    --  Calls Process for each node in hash table HT
 
-   generic
-      use Ada.Streams;
-      with procedure Write
-        (Stream : not null access Root_Stream_Type'Class;
-         Node   : Node_Type);
-   procedure Generic_Write
-     (Stream : not null access Root_Stream_Type'Class;
-      HT     : Hash_Table_Type);
-   --  Used to implement the streaming attribute for hashed containers. It
-   --  calls Write for each node to write its value into Stream.
-
-   generic
-      use Ada.Streams;
-      with function New_Node (Stream : not null access Root_Stream_Type'Class)
-         return Count_Type;
-   procedure Generic_Read
-     (Stream : not null access Root_Stream_Type'Class;
-      HT     : out Hash_Table_Type);
-   --  Used to implement the streaming attribute for hashed containers. It
-   --  first clears hash table HT, then populates the hash table by calling
-   --  New_Node for each item in Stream.
-
 end Ada.Containers.Hash_Tables.Generic_Formal_Operations;