changeset 775:85253619d522

vflist_maint(): only allocate memory and compare strings if needed.
author zas_
date Tue, 03 Jun 2008 07:37:24 +0000
parents e095a66b428f
children 9c962ffe8edc
files src/view_file_list.c
diffstat 1 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/view_file_list.c	Tue Jun 03 07:32:13 2008 +0000
+++ b/src/view_file_list.c	Tue Jun 03 07:37:24 2008 +0000
@@ -1862,22 +1862,30 @@
 
 void vflist_maint(ViewFile *vf, FileData *fd)
 {
-	gchar *source_base;
-	gchar *dest_base;
-	
+	gboolean refresh;
+
 	if (vf->refresh_idle_id != -1) return;
 	
-	source_base = remove_level_from_path(fd->change->source);
-	dest_base = remove_level_from_path(fd->change->dest);
+	refresh = (strcmp(fd->path, vf->path) == 0);
+
+	if (!refresh)
+		{
+		gchar *dest_base = remove_level_from_path(fd->change->dest);
+		refresh = (strcmp(dest_base, vf->path) == 0);
+		g_free(dest_base);
+		}
 
-	if (strcmp(source_base, vf->path) == 0 ||
-	    strcmp(dest_base, vf->path) == 0 ||
-	    strcmp(fd->path, vf->path) == 0)
+	if (!refresh)
+		{
+		gchar *source_base = remove_level_from_path(fd->change->source);
+		refresh = (strcmp(source_base, vf->path) == 0);
+		g_free(source_base);
+		}
+	
+	if (refresh)
 		{
 		vf->refresh_idle_id = g_idle_add(vflist_refresh_idle_cb, vf);
 		}
-	g_free(source_base);
-	g_free(dest_base);
 }
 
 /* the plan is to drop these functions and use vflist_maint directly */