Commit 0254870f authored by Matthias Clasen's avatar Matthias Clasen
Browse files

layout: Small optimization

Don't calculate line width the hard way when
we can do it much easier.
parent 253461f9
......@@ -3269,6 +3269,7 @@ pango_layout_line_leaked (PangoLayoutLine *line)
static void shape_tab (PangoLayoutLine *line,
LastTabState *tab_state,
int current_width,
PangoItem *item,
PangoGlyphString *glyphs);
......@@ -3456,27 +3457,6 @@ get_tab_pos (PangoLayoutLine *line,
*tab_pos -= offset;
}
static int
line_width (PangoLayoutLine *line)
{
GSList *l;
int i;
int width = 0;
/* Compute the width of the line currently - inefficient, but easier
* than keeping the current width of the line up to date everywhere
*/
for (l = line->runs; l; l = l->next)
{
PangoLayoutRun *run = l->data;
for (i = 0; i < run->glyphs->num_glyphs; i++)
width += run->glyphs->glyphs[i].geometry.width;
}
return width;
}
static gboolean
showing_space (const PangoAnalysis *analysis)
{
......@@ -3513,17 +3493,15 @@ struct _LastTabState {
static void
shape_tab (PangoLayoutLine *line,
LastTabState *tab_state,
int current_width,
PangoItem *item,
PangoGlyphString *glyphs)
{
int i, space_width;
int current_width;
int tab_pos;
PangoTabAlign tab_align;
gunichar tab_decimal;
current_width = line_width (line);
pango_glyph_string_set_size (glyphs, 1);
if (showing_space (&item->analysis))
......@@ -3707,7 +3685,7 @@ shape_run (PangoLayoutLine *line,
PangoGlyphString *glyphs = pango_glyph_string_new ();
if (layout->text[item->offset] == '\t')
shape_tab (line, &state->last_tab, item, glyphs);
shape_tab (line, &state->last_tab, state->line_width - state->remaining_width, item, glyphs);
else
{
PangoShapeFlags shape_flags = PANGO_SHAPE_NONE;
......
......@@ -52,7 +52,7 @@
"is-wrapped" : true,
"is-ellipsized" : false,
"unknown-glyphs" : 1,
"width" : 179200,
"width" : 202752,
"height" : 38912,
"log-attrs" : [
{
......@@ -258,7 +258,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 43008,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -330,7 +330,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 43008,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -402,7 +402,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 44032,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -554,7 +554,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 43008,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -626,7 +626,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 46080,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -698,7 +698,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 43008,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......
......@@ -53,7 +53,7 @@
"is-wrapped" : false,
"is-ellipsized" : false,
"unknown-glyphs" : 1,
"width" : 315392,
"width" : 386048,
"height" : 19456,
"log-attrs" : [
{
......@@ -271,7 +271,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 43008,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -355,7 +355,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 43008,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -439,7 +439,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 44032,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -607,7 +607,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 17408,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -691,7 +691,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 46080,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......@@ -775,7 +775,7 @@
"glyphs" : [
{
"glyph" : 268435455,
"width" : 43008,
"width" : 51200,
"is-cluster-start" : true,
"log-cluster" : 0
}
......
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