(expand_format): minor optimization.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-02-15 21:38:59 +03:00 committed by Slava Zanko
parent 53b146c83a
commit 4bd81f5866

View File

@ -869,32 +869,31 @@ expand_format (struct WEdit *edit_widget, char c, gboolean do_quote)
case 't':
case 'u':
{
int length = 2, i;
char *block, *tmp;
GString *block;
int i;
if (!panel)
if (panel == NULL)
{
result = g_strdup ("");
goto ret;
}
for (i = 0; i < panel->count; i++)
if (panel->dir.list[i].f.marked)
length += strlen (panel->dir.list[i].fname) + 1; /* for space */
block = g_string_sized_new (16);
block = g_malloc (length * 2 + 1);
*block = 0;
for (i = 0; i < panel->count; i++)
if (panel->dir.list[i].f.marked)
{
char *tmp;
tmp = (*quote_func) (panel->dir.list[i].fname, 0);
strcat (block, tmp);
g_string_append (block, tmp);
g_string_append_c (block, ' ');
g_free (tmp);
strcat (block, " ");
if (c_lc == 'u')
do_file_mark (panel, i, 0);
}
result = block;
result = g_string_free (block, FALSE);
goto ret;
} /* sub case block */
} /* switch */