This will reduce significantly the number of allocations done when
doing consecutive append operations.
Tested on x86_64-pc-linux-gnu, committed on trunk
2018-07-16 Nicolas Roche <ro...@adacore.com>
gcc/ada/
* libgnat/a-strunb.adb, libgnat/a-strunb__shared.adb: Adjust growth
factor from 1/32 to 1/2 for Unbounded_String.
--- gcc/ada/libgnat/a-strunb.adb
+++ gcc/ada/libgnat/a-strunb.adb
@@ -763,13 +763,13 @@ package body Ada.Strings.Unbounded is
(Source : in out Unbounded_String;
Chunk_Size : Natural)
is
- Growth_Factor : constant := 32;
+ Growth_Factor : constant := 2;
-- The growth factor controls how much extra space is allocated when
-- we have to increase the size of an allocated unbounded string. By
-- allocating extra space, we avoid the need to reallocate on every
-- append, particularly important when a string is built up by repeated
-- append operations of small pieces. This is expressed as a factor so
- -- 32 means add 1/32 of the length of the string as growth space.
+ -- 2 means add 1/2 of the length of the string as growth space.
Min_Mul_Alloc : constant := Standard'Maximum_Alignment;
-- Allocation will be done by a multiple of Min_Mul_Alloc This causes
--- gcc/ada/libgnat/a-strunb__shared.adb
+++ gcc/ada/libgnat/a-strunb__shared.adb
@@ -36,13 +36,13 @@ package body Ada.Strings.Unbounded is
use Ada.Strings.Maps;
- Growth_Factor : constant := 32;
+ Growth_Factor : constant := 2;
-- The growth factor controls how much extra space is allocated when
-- we have to increase the size of an allocated unbounded string. By
-- allocating extra space, we avoid the need to reallocate on every
-- append, particularly important when a string is built up by repeated
-- append operations of small pieces. This is expressed as a factor so
- -- 32 means add 1/32 of the length of the string as growth space.
+ -- 2 means add 1/2 of the length of the string as growth space.
Min_Mul_Alloc : constant := Standard'Maximum_Alignment;
-- Allocation will be done by a multiple of Min_Mul_Alloc. This causes