This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Efficiency improvement in bounded ordered containers


The Delete operations in the bounded ordered containers have been
substantially sped up.  No change in semantics, so no test.

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

2019-08-20  Bob Duff  <duff@adacore.com>

gcc/ada/

	* libgnat/a-cborma.adb, libgnat/a-cborse.adb (Clear): Repeatedly
	call Delete. This avoids clearing the free list, which
	substantially speeds up future Delete operations.
--- gcc/ada/libgnat/a-cborma.adb
+++ gcc/ada/libgnat/a-cborma.adb
@@ -374,7 +374,9 @@ package body Ada.Containers.Bounded_Ordered_Maps is
 
    procedure Clear (Container : in out Map) is
    begin
-      Tree_Operations.Clear_Tree (Container);
+      while not Container.Is_Empty loop
+         Container.Delete_Last;
+      end loop;
    end Clear;
 
    -----------

--- gcc/ada/libgnat/a-cborse.adb
+++ gcc/ada/libgnat/a-cborse.adb
@@ -374,7 +374,9 @@ package body Ada.Containers.Bounded_Ordered_Sets is
 
    procedure Clear (Container : in out Set) is
    begin
-      Tree_Operations.Clear_Tree (Container);
+      while not Container.Is_Empty loop
+         Container.Delete_Last;
+      end loop;
    end Clear;
 
    -----------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]