Skip to content

Commit

Permalink
Cache strcmp() result.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Monin committed Jul 28, 2008
1 parent 660c688 commit 6eac9ec
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/filedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,18 +1595,21 @@ gint file_data_verify_ci(FileData *fd)

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;
DEBUG_1("Change checked: source and destination have different extensions: %s -> %s", fd->path, fd->change->dest);
}

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);
Expand All @@ -1624,7 +1627,7 @@ gint file_data_verify_ci(FileData *fd)
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))
{
Expand All @@ -1637,7 +1640,7 @@ gint file_data_verify_ci(FileData *fd)
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);
Expand Down

0 comments on commit 6eac9ec

Please sign in to comment.