Commit e05a1ce7 by Nicolas Roche Committed by Pierre-Marie de Rodat

[Ada] Adjust growth factor from 1/32 to 1/2 for Unbounded_String

This will reduce significantly the number of allocations done when
doing consecutive append operations.

2018-07-16  Nicolas Roche  <roche@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.

From-SVN: r262697
parent 0150d9a1
2018-07-16 Nicolas Roche <roche@adacore.com>
* libgnat/a-strunb.adb, libgnat/a-strunb__shared.adb: Adjust growth
factor from 1/32 to 1/2 for Unbounded_String.
2018-07-13 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/lang.opt (funsigned-char): New option.
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment