# HG changeset patch # User zas_ # Date 1217267949 0 # Node ID 1e61dac76311a93388183bacec947afced56a5b0 # Parent 77a1d5a0326d1bbbf648f620f207c6247ef9e4bd Cache strcmp() result. diff -r 77a1d5a0326d -r 1e61dac76311 src/filedata.c --- 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);