Avoiding a pointless lstat() when not writing to a temporary file.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5616 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
05334a2b3c
commit
12f27299f1
|
@ -1,6 +1,8 @@
|
||||||
2016-02-07 Benno Schulenberg <bensberg@justemail.net>
|
2016-02-07 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/files.c (update_poshistory): Don't put files in the history list
|
* src/files.c (update_poshistory): Don't put files in the history list
|
||||||
when they have the default cursor position (line 1, column 1).
|
when they have the default cursor position (line 1, column 1).
|
||||||
|
* src/files.c (write_file): Avoid a pointless lstat() when not writing
|
||||||
|
to a temp file, and in the bargain elide two variables.
|
||||||
|
|
||||||
2016-02-06 Benno Schulenberg <bensberg@justemail.net>
|
2016-02-06 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/files.c (write_file): Remove the --nofollow option that hasn't
|
* src/files.c (write_file): Remove the --nofollow option that hasn't
|
||||||
|
|
11
src/files.c
11
src/files.c
|
@ -1760,14 +1760,9 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
/* The result of stat(). TRUE if the file exists, FALSE
|
/* The result of stat(). TRUE if the file exists, FALSE
|
||||||
* otherwise. If name is a link that points nowhere, realexists
|
* otherwise. If name is a link that points nowhere, realexists
|
||||||
* is FALSE. */
|
* is FALSE. */
|
||||||
|
#endif
|
||||||
struct stat st;
|
struct stat st;
|
||||||
/* The status fields filled in by stat(). */
|
/* The status fields filled in by stat(). */
|
||||||
#endif
|
|
||||||
bool anyexists;
|
|
||||||
/* The result of lstat(). The same as realexists, unless name
|
|
||||||
* is a link. */
|
|
||||||
struct stat lst;
|
|
||||||
/* The status fields filled in by lstat(). */
|
|
||||||
char *realname;
|
char *realname;
|
||||||
/* name after tilde expansion. */
|
/* name after tilde expansion. */
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
@ -1797,10 +1792,8 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
anyexists = (lstat(realname, &lst) != -1);
|
|
||||||
|
|
||||||
/* If the temp file exists and isn't already open, give up. */
|
/* If the temp file exists and isn't already open, give up. */
|
||||||
if (tmp && anyexists && f_open == NULL)
|
if (tmp && (lstat(realname, &st) != -1) && f_open == NULL)
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
|
Loading…
Reference in New Issue