[Ada] Efficiency improvement in bounded ordered containers
diff mbox series

Message ID 20190820095121.GA75446@adacore.com
State New
Headers show
Series
  • [Ada] Efficiency improvement in bounded ordered containers
Related show

Commit Message

Pierre-Marie de Rodat Aug. 20, 2019, 9:51 a.m. UTC
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.

Patch
diff mbox series

--- 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;
 
    -----------