Don't recreate every string everytime.

This commit is contained in:
Dave Davenport 2017-02-03 20:49:16 +01:00
parent 2fe22cb7e2
commit 8ef7b4b794
9 changed files with 89 additions and 88 deletions

View file

@ -237,12 +237,12 @@ static void listview_recompute_elements ( listview *lv )
}
lv->boxes = g_realloc ( lv->boxes, newne * sizeof ( textbox* ) );
if ( newne > 0 ) {
char *name = g_strjoin ( ".", lv->listview_name, "element", NULL );
for ( unsigned int i = lv->cur_elements; i < newne; i++ ) {
TextboxFlags flags = ( lv->multi_select ) ? TB_INDICATOR : 0;
char *name = g_strjoin ( ".", lv->listview_name, "element", NULL );
lv->boxes[i] = textbox_create ( name, flags, NORMAL, "" );
g_free ( name );
}
g_free ( name );
}
lv->rchanged = TRUE;
lv->cur_elements = newne;

View file

@ -59,7 +59,8 @@ static PangoContext *p_context = NULL;
static PangoFontMetrics *p_metrics = NULL;
/** Cache to hold font descriptions. This it to avoid having to lookup each time. */
typedef struct TBFontConfig {
typedef struct TBFontConfig
{
/** Font description */
PangoFontDescription *pfd;
/** Font metrics */
@ -129,7 +130,8 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType
if ( helper_validate_font ( tbfc->pfd, font ) ) {
tbfc->metrics = pango_context_get_metrics ( p_context, tbfc->pfd, NULL );
g_hash_table_insert ( tbfc_cache, font, tbfc );
} else {
}
else {
pango_font_description_free ( tbfc->pfd );
g_free ( tbfc );
tbfc = NULL;
@ -142,7 +144,6 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType
}
}
if ( ( flags & TB_WRAP ) == TB_WRAP ) {
pango_layout_set_wrap ( tb->layout, PANGO_WRAP_WORD_CHAR );
}