summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baird <baird@adacore.com>2025-11-10 14:36:33 -0800
committerMarc Poulhiès <dkm@gcc.gnu.org>2025-11-21 09:29:36 +0100
commitf4312f92c0b723c607419844818b075b8c020b9c (patch)
tree3b528e502f47473fc3e3d89f49a58dba999ec27e
parent3cd98d416526624d176e421b0cca05b51d6ee1d9 (diff)
ada: Improve Append performance for Ada.Containers.Bounded_Vectors
In (any instance of) Ada.Containers.Bounded_Vectors, for the procedure overload of Append that takes parameters of types Vector and Element_Type, improve performance in the case where either of the GNAT-defined checks Container_Checks or Tampering_Check are suppressed. gcc/ada/ChangeLog: * libgnat/a-cobove.adb (Append): Add an equivalent fast path for the case where tampering checks are suppressed.
-rw-r--r--gcc/ada/libgnat/a-cobove.adb10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/ada/libgnat/a-cobove.adb b/gcc/ada/libgnat/a-cobove.adb
index 3b5b4a61bf5..6371fb57d28 100644
--- a/gcc/ada/libgnat/a-cobove.adb
+++ b/gcc/ada/libgnat/a-cobove.adb
@@ -363,7 +363,15 @@ package body Ada.Containers.Bounded_Vectors is
New_Item : Element_Type)
is
begin
- Insert (Container, Last_Index (Container) + 1, New_Item, 1);
+ if T_Check then
+ -- handle the general case
+ Insert (Container, Last_Index (Container) + 1, New_Item, 1);
+ else
+ -- The fast path.
+ -- The first (but not the second) statement may fail a check.
+ Container.Elements (To_Array_Index (Container.Last) + 1) := New_Item;
+ Container.Last := Container.Last + 1;
+ end if;
end Append;
--------------