about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-23 12:47:16 +0000
committerbors <bors@rust-lang.org>2015-05-23 12:47:16 +0000
commitd11399039caa83e41378ac7efbb250fdb5d0ad27 (patch)
tree4959cd38bca4a997062b518bc6fa19107ca612d1
parent4c2ebc3947568f5ca11c4e8a97538296b4f78285 (diff)
parente7aad2861422a4fb65808d2a8a6dbeb22e6a0c1d (diff)
downloadrust-d11399039caa83e41378ac7efbb250fdb5d0ad27.tar.gz
rust-d11399039caa83e41378ac7efbb250fdb5d0ad27.zip
Auto merge of #25632 - alexcrichton:dt-dir, r=brson
This "fast path" in `DirEntry::file_type` on Unix wasn't turning out to be so
much of a fast path as the `DT_DIR` case wasn't handled, so directories fell
back to using `lstat` instead. This commit adds the missing case to return
quickly if a path is a directory and `DirEntry::file_type` is used.
-rw-r--r--src/rt/rust_builtin.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/rt/rust_builtin.c b/src/rt/rust_builtin.c
index 92371e90aba..1a2917a1dd6 100644
--- a/src/rt/rust_builtin.c
+++ b/src/rt/rust_builtin.c
@@ -59,7 +59,7 @@ rust_list_dir_val(struct dirent* entry_ptr) {
 
 int
 rust_dir_get_mode(struct dirent* entry_ptr) {
-#if defined(_DIRENT_HAVE_D_TYPE)
+#if defined(_DIRENT_HAVE_D_TYPE) || defined(__APPLE__)
     switch (entry_ptr->d_type) {
         case DT_BLK: return S_IFBLK;
         case DT_CHR: return S_IFCHR;
@@ -67,6 +67,7 @@ rust_dir_get_mode(struct dirent* entry_ptr) {
         case DT_LNK: return S_IFLNK;
         case DT_REG: return S_IFREG;
         case DT_SOCK: return S_IFSOCK;
+        case DT_DIR: return S_IFDIR;
     }
 #endif
     return -1;