Re: pango_layout_set_text_static
- From: Behdad Esfahbod <behdad cs toronto edu>
- To: Morten Welinder <mwelinder gmail com>
- Cc: Performance-list gnome org
- Subject: Re: pango_layout_set_text_static
- Date: Fri, 28 Apr 2006 16:57:24 -0400 (EDT)
On Fri, 28 Apr 2006, Morten Welinder wrote:
> I was thinking that a pango_layout_set_text_static where the caller would
> ensure that the string would outlive the layout in the sense that after the
> string was no longer valid, you could only...
I was thinking about it the other day. There are currently two
reasons that pango_layout_set_text copies the text (other than
for keeping it around) that the static version should address:
- Make sure the text is nul-terminated, even if you pass a
length,
- Make sure the text is valid UTF-8. We currently replace
invalid bytes with '?', but that will change soon and -1 used
instead!
Both of these assumptions are used all over the Pango down the
road and cannot be relaxed. So the static version should take no
length (assume -1), and reject if text is not valid. Another
option is to transparently copy it internally and fix the invalid
codepoints and manage its lifecycle itself. This cannot quite be
done for the length issue AFAIU, as we are not allowed to examine
the length+1'th byte of the string to see if it's nul or not.
> 1. Set a new string.
> 2. Use as a gobject, ie., ref, unref, connect and disconnect signals etc.
Both look fine. I was also thinking along the lines having kind
of a freeze operation on the layout, that will:
- make sure it has layed out text,
- free its copy of the text if it owns it,
- do not relayout anymore, even if you change layout properties.
Not sure which approach makes more sense.
> With a little cooperation from GtkLabel and friends this ought to save a
> few pages per app.
>
> Comments?
> Morten
--behdad
http://behdad.org/
"Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
-- Dan Bern, "New American Language"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]