changeset 953:1e61dac76311

Cache strcmp() result.
author zas_
date Mon, 28 Jul 2008 17:59:09 +0000
parents 77a1d5a0326d
children ed0fc0986928
files src/filedata.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Mon Jul 28 17:56:56 2008 +0000
+++ b/src/filedata.c	Mon Jul 28 17:59:09 2008 +0000
@@ -1595,10 +1595,13 @@
 
 	if (fd->change->dest)
 		{
+		gboolean same;
 		gchar *dest_dir;
 		const gchar *dest_ext = extension_from_path(fd->change->dest);
 		if (!dest_ext) dest_ext = "";
 		
+		same = (strcmp(fd->path, fd->change->dest) == 0);
+
 		if (strcasecmp(fd->extension, dest_ext) != 0)
 			{
 			ret |= CHANGE_WARN_CHANGED_EXT;
@@ -1606,7 +1609,7 @@
 		}
 
 		if (fd->change->type != FILEDATA_CHANGE_UNSPECIFIED && /* FIXME this is now needed for running editors */
-		    strcmp(fd->path, fd->change->dest) == 0)
+		    same)
 			{
 			ret |= CHANGE_WARN_SAME;
 			DEBUG_1("Change checked: source and destination are the same: %s -> %s", fd->path, fd->change->dest);
@@ -1624,7 +1627,7 @@
 			ret |= CHANGE_NO_WRITE_PERM_DEST_DIR;
 			DEBUG_1("Change checked: destination dir is readonly: %s -> %s", fd->path, fd->change->dest);
 			}
-		else if (isfile(fd->change->dest) && (strcmp(fd->change->dest, fd->path) != 0))
+		else if (isfile(fd->change->dest) && !same)
 			{
 			if (!access_file(fd->change->dest, W_OK))
 				{
@@ -1637,7 +1640,7 @@
 				DEBUG_1("Change checked: destination exists: %s -> %s", fd->path, fd->change->dest);
 				}
 			}
-		else if (isdir(fd->change->dest) && (strcmp(fd->change->dest, fd->path) != 0))
+		else if (isdir(fd->change->dest) && !same)
 			{
 			ret |= CHANGE_DEST_EXISTS;
 			DEBUG_1("Change checked: destination exists: %s -> %s", fd->path, fd->change->dest);