mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -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:
parent
278dfd7f76
commit
1e3e062b24
@ -353,7 +353,7 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
|
||||
} else {
|
||||
/* hilight part of the line */
|
||||
GString *tmp;
|
||||
char *middle, *lastcolor;
|
||||
char *middle;
|
||||
int pos, color_pos, color_len;
|
||||
|
||||
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,
|
||||
&color_pos, &color_len);
|
||||
if (color_pos > 0)
|
||||
lastcolor = g_strndup(text+color_pos, color_len);
|
||||
g_string_append_len(tmp, text+color_pos, color_len);
|
||||
else {
|
||||
/* no colors in line, change back to default */
|
||||
lastcolor = g_malloc0(3);
|
||||
lastcolor[0] = 4;
|
||||
lastcolor[1] = FORMAT_STYLE_DEFAULTS;
|
||||
g_string_append_c(tmp, 4);
|
||||
g_string_append_c(tmp, FORMAT_STYLE_DEFAULTS);
|
||||
}
|
||||
g_string_append(tmp, lastcolor);
|
||||
g_string_append(tmp, text+pos);
|
||||
g_free(lastcolor);
|
||||
|
||||
newstr = tmp->str;
|
||||
g_string_free(tmp, FALSE);
|
||||
|
Loading…
Reference in New Issue
Block a user