From 4e9ff1dd6ee3ea63fd91a76a91d9725a10a294a0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 15 Aug 2011 16:21:22 +0200 Subject: [PATCH] Pre-allocate buffers when adding string We do a conservative estimate of the number of characters, but still, this limits the number of buffer reallocs to a small constant. --- src/hb-buffer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 3be3f4438..3f46d686e 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -723,6 +723,7 @@ hb_buffer_guess_properties (hb_buffer_t *buffer) } \ if (item_length == -1) \ item_length = text_length - item_offset; \ + buffer->ensure (buffer->len + item_length * sizeof (T) / 4); \ const T *next = (const T *) text + item_offset; \ const T *end = next + item_length; \ while (next < end) { \