[pango/wip/baedert/for-master: 45/61] layout: Avoid getting the text length if we know it already
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/wip/baedert/for-master: 45/61] layout: Avoid getting the text length if we know it already
- Date: Mon, 8 Jun 2020 17:05:35 +0000 (UTC)
commit d8e5dab10ca6d0f6362f74eead03f9ad44416405
Author: Timm Bäder <mail baedert org>
Date: Fri Apr 17 07:17:43 2020 +0200
layout: Avoid getting the text length if we know it already
pango/pango-layout.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index f6d37068..2de3f9eb 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -1125,15 +1125,22 @@ pango_layout_set_text (PangoLayout *layout,
old_text = layout->text;
if (length < 0)
- layout->text = g_strdup (text);
+ {
+ layout->length = strlen (text);
+ layout->text = g_strndup (text, layout->length);
+ }
else if (length > 0)
- /* This is not exactly what we want. We don't need the padding...
- */
- layout->text = g_strndup (text, length);
+ {
+ /* This is not exactly what we want. We don't need the padding...
+ */
+ layout->length = length;
+ layout->text = g_strndup (text, length);
+ }
else
- layout->text = g_malloc0 (1);
-
- layout->length = strlen (layout->text);
+ {
+ layout->length = 0;
+ layout->text = g_malloc0 (1);
+ }
/* validate it, and replace invalid bytes with -1 */
start = layout->text;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]