[gcc r16-5470] ada: Improve Append performance for Ada.Containers.Bounded_Vectors
Marc Poulhies
dkm@gcc.gnu.org
Fri Nov 21 08:31:11 GMT 2025
https://gcc.gnu.org/g:f4312f92c0b723c607419844818b075b8c020b9c
commit r16-5470-gf4312f92c0b723c607419844818b075b8c020b9c
Author: Steve Baird <baird@adacore.com>
Date: Mon Nov 10 14:36:33 2025 -0800
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.
Diff:
---
gcc/ada/libgnat/a-cobove.adb | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/libgnat/a-cobove.adb b/gcc/ada/libgnat/a-cobove.adb
index 3b5b4a61bf5b..6371fb57d28a 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;
--------------
More information about the Gcc-cvs
mailing list