1
0
mirror of https://github.com/irssi/irssi.git synced 2024-08-04 03:34:18 -04:00

Simplify, append directly to GString rather than allocating a

temporary string.


git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4854 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Emanuele Giaquinta 2008-05-31 13:18:43 +00:00 committed by exg
parent 278dfd7f76
commit 1e3e062b24

View File

@ -353,7 +353,7 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
} else { } else {
/* hilight part of the line */ /* hilight part of the line */
GString *tmp; GString *tmp;
char *middle, *lastcolor; char *middle;
int pos, color_pos, color_len; int pos, color_pos, color_len;
tmp = g_string_new(NULL); tmp = g_string_new(NULL);
@ -377,16 +377,13 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
pos = strip_real_length(text, hilight_end, pos = strip_real_length(text, hilight_end,
&color_pos, &color_len); &color_pos, &color_len);
if (color_pos > 0) if (color_pos > 0)
lastcolor = g_strndup(text+color_pos, color_len); g_string_append_len(tmp, text+color_pos, color_len);
else { else {
/* no colors in line, change back to default */ /* no colors in line, change back to default */
lastcolor = g_malloc0(3); g_string_append_c(tmp, 4);
lastcolor[0] = 4; g_string_append_c(tmp, FORMAT_STYLE_DEFAULTS);
lastcolor[1] = FORMAT_STYLE_DEFAULTS;
} }
g_string_append(tmp, lastcolor);
g_string_append(tmp, text+pos); g_string_append(tmp, text+pos);
g_free(lastcolor);
newstr = tmp->str; newstr = tmp->str;
g_string_free(tmp, FALSE); g_string_free(tmp, FALSE);