diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-03-18 13:02:13 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-03-20 08:44:40 +0000 |
commit | 698203ab28bc679c2e62a2452a79d5785fd46ca7 (patch) | |
tree | a2d0086444a6a25500283210cd340daca899ece7 /pango/break.c | |
parent | 3241972c4f4d9c1d98d166c38cb0d7b12afb5545 (diff) | |
download | pango-698203ab28bc679c2e62a2452a79d5785fd46ca7.tar.gz |
[pango] Allocate PangoScriptIter on stack.
Move the PangoScriptIter structure definition to a private header file,
so that we can embed the iterator within other structures or allocate
a local iterator on the stack. This eliminates the frequent short-lived
allocations associated with the iterator.
Diffstat (limited to 'pango/break.c')
-rw-r--r-- | pango/break.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pango/break.c b/pango/break.c index db3053a7..fa49b3fc 100644 --- a/pango/break.c +++ b/pango/break.c @@ -23,6 +23,7 @@ #include "pango-break.h" #include "pango-modules.h" +#include "pango-script-private.h" #include <string.h> #define PARAGRAPH_SEPARATOR 0x2029 @@ -1864,7 +1865,7 @@ pango_get_log_attrs (const char *text, static guint engine_type_id = 0; static guint render_type_id = 0; PangoAnalysis analysis = { NULL }; - PangoScriptIter *iter; + PangoScriptIter iter; g_return_if_fail (length == 0 || text != NULL); g_return_if_fail (log_attrs != NULL); @@ -1883,17 +1884,17 @@ pango_get_log_attrs (const char *text, chars_broken = 0; - iter = pango_script_iter_new (text, length); - pango_script_iter_get_range (iter, &range_start, &range_end, &script); + _pango_script_iter_init (&iter, text, length); + pango_script_iter_get_range (&iter, &range_start, &range_end, &script); range_engine = (PangoEngineLang*) pango_map_get_engine (lang_map, script); g_assert (range_start == text); - while (pango_script_iter_next (iter)) + while (pango_script_iter_next (&iter)) { const char *run_start, *run_end; PangoEngineLang* run_engine; - pango_script_iter_get_range (iter, &run_start, &run_end, &script); + pango_script_iter_get_range (&iter, &run_start, &run_end, &script); run_engine = (PangoEngineLang*) pango_map_get_engine (lang_map, script); g_assert (range_end == run_start); @@ -1909,7 +1910,7 @@ pango_get_log_attrs (const char *text, } range_end = run_end; } - pango_script_iter_free (iter); + _pango_script_iter_fini (&iter); g_assert (length < 0 || range_end == text + length); |