[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111226: Speed up most calls to 'stat
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111226: Speed up most calls to 'stat' and 'lstat' on MS-Windows. |
Date: |
Fri, 14 Dec 2012 16:05:01 +0200 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111226
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Fri 2012-12-14 16:05:01 +0200
message:
Speed up most calls to 'stat' and 'lstat' on MS-Windows.
src/w32.c (stat_worker): If w32_stat_get_owner_group is zero, do not
try to get accurate owner and group information from NT file
security APIs. This is to make most callers of 'stat' and
'lstat', which don't need that information, much faster.
src/dired.c (Ffile_attributes) [WINDOWSNT]: Set
w32_stat_get_owner_group to a non-zero value, to request accurate
owner and group information from 'lstat'.
nt/inc/sys/stat.h: Declare w32_stat_get_owner_group.
modified:
nt/ChangeLog
nt/inc/sys/stat.h
src/ChangeLog
src/dired.c
src/w32.c
=== modified file 'nt/ChangeLog'
--- a/nt/ChangeLog 2012-12-13 05:29:15 +0000
+++ b/nt/ChangeLog 2012-12-14 14:05:01 +0000
@@ -1,3 +1,7 @@
+2012-12-14 Eli Zaretskii <address@hidden>
+
+ * inc/sys/stat.h: Declare w32_stat_get_owner_group.
+
2012-12-13 Juanma Barranquero <address@hidden>
* config.nt: Sync with autogen/config.in.
=== modified file 'nt/inc/sys/stat.h'
--- a/nt/inc/sys/stat.h 2012-08-03 10:23:30 +0000
+++ b/nt/inc/sys/stat.h 2012-12-14 14:05:01 +0000
@@ -98,6 +98,10 @@
char st_gname[260];
};
+/* Internal variable for asking 'stat'/'lstat' to produce accurate
+ info about owner and group of files. */
+extern int w32_stat_get_owner_group;
+
/* Prevent redefinition by other headers, e.g. wchar.h. */
#define _STAT_DEFINED
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2012-12-13 19:35:10 +0000
+++ b/src/ChangeLog 2012-12-14 14:05:01 +0000
@@ -1,3 +1,14 @@
+2012-12-14 Eli Zaretskii <address@hidden>
+
+ * w32.c (stat_worker): If w32_stat_get_owner_group is zero, do not
+ try to get accurate owner and group information from NT file
+ security APIs. This is to make most callers of 'stat' and
+ 'lstat', which don't need that information, much faster.
+
+ * dired.c (Ffile_attributes) [WINDOWSNT]: Set
+ w32_stat_get_owner_group to a non-zero value, to request accurate
+ owner and group information from 'lstat'.
+
2012-12-13 Paul Eggert <address@hidden>
* fileio.c (Finsert_file_contents): Don't put tail into head area,
=== modified file 'src/dired.c'
--- a/src/dired.c 2012-11-27 05:38:42 +0000
+++ b/src/dired.c 2012-12-14 14:05:01 +0000
@@ -895,6 +895,7 @@
Lisp_Object dirname;
struct stat sdir;
#endif /* BSD4_2 */
+ int lstat_result;
/* An array to hold the mode string generated by filemodestring,
including its terminating space and null byte. */
@@ -922,7 +923,21 @@
encoded = ENCODE_FILE (filename);
UNGCPRO;
- if (lstat (SSDATA (encoded), &s) < 0)
+#ifdef WINDOWSNT
+ /* We usually don't request accurate owner and group info, because
+ it can be very expensive on Windows to get that, and most callers
+ of 'lstat' don't need that. But here we do want that information
+ to be accurate. */
+ w32_stat_get_owner_group = 1;
+#endif
+
+ lstat_result = lstat (SSDATA (encoded), &s);
+
+#ifdef WINDOWSNT
+ w32_stat_get_owner_group = 0;
+#endif
+
+ if (lstat_result < 0)
return Qnil;
values[0] = (S_ISLNK (s.st_mode) ? Ffile_symlink_p (filename)
=== modified file 'src/w32.c'
--- a/src/w32.c 2012-12-10 02:00:42 +0000
+++ b/src/w32.c 2012-12-14 14:05:01 +0000
@@ -3537,6 +3537,10 @@
return !(devtype == DRIVE_FIXED || devtype == DRIVE_RAMDISK);
}
+/* If this is non-zero, the caller wants accurate information about
+ file's owner and group, which could be expensive to get. */
+int w32_stat_get_owner_group;
+
/* MSVC stat function can't cope with UNC names and has other bugs, so
replace it with our own. This also allows us to calculate consistent
inode values and owner/group without hacks in the main Emacs code. */
@@ -3708,6 +3712,7 @@
/* We produce the fallback owner and group data, based on the
current user that runs Emacs, in the following cases:
+ . caller didn't request owner and group info
. this is Windows 9X
. getting security by handle failed, and we need to produce
information for the target of a symlink (this is better
@@ -3716,23 +3721,25 @@
If getting security by handle fails, and we don't need to
resolve symlinks, we try getting security by name. */
- if (is_windows_9x () != TRUE)
- psd = get_file_security_desc_by_handle (fh);
- if (psd)
- {
- get_file_owner_and_group (psd, name, buf);
- LocalFree (psd);
- }
- else if (is_windows_9x () == TRUE)
+ if (!w32_stat_get_owner_group || is_windows_9x () == TRUE)
get_file_owner_and_group (NULL, name, buf);
- else if (!(is_a_symlink && follow_symlinks))
- {
- psd = get_file_security_desc_by_name (name);
- get_file_owner_and_group (psd, name, buf);
- xfree (psd);
- }
else
- get_file_owner_and_group (NULL, name, buf);
+ {
+ psd = get_file_security_desc_by_handle (fh);
+ if (psd)
+ {
+ get_file_owner_and_group (psd, name, buf);
+ LocalFree (psd);
+ }
+ else if (!(is_a_symlink && follow_symlinks))
+ {
+ psd = get_file_security_desc_by_name (name);
+ get_file_owner_and_group (psd, name, buf);
+ xfree (psd);
+ }
+ else
+ get_file_owner_and_group (NULL, name, buf);
+ }
CloseHandle (fh);
}
else
@@ -6849,6 +6856,9 @@
/* "None" is the default group name on standalone workstations. */
strcpy (dflt_group_name, "None");
+
+ /* Reset, in case it has some value inherited from dump time. */
+ w32_stat_get_owner_group = 0;
}
/* For make-serial-process */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111226: Speed up most calls to 'stat' and 'lstat' on MS-Windows.,
Eli Zaretskii <=