aboutsummaryrefslogtreecommitdiff
path: root/src/dir.cc
diff options
context:
space:
mode:
authorRoman Perepelitsa <roman.perepelitsa@gmail.com>2020-06-14 11:29:29 +0300
committerRoman Perepelitsa <roman.perepelitsa@gmail.com>2020-06-14 11:29:29 +0300
commit0717e57ff46201ff04e7d62cda8677e174a83be6 (patch)
treea965388ce18d5a10a3d77d8755aac97e96f0d1da /src/dir.cc
parentb0158178925484c058e6175e174b639237532c63 (diff)
Squashed 'gitstatus/' changes from 1c74c8db..0d23fbd1
0d23fbd1 comments 9c19c9c4 fix a typo in install that prevents the locally built gitstatusd from being used 92fd143f doc cleanup git-subtree-dir: gitstatus git-subtree-split: 0d23fbd117ad6afe52fdbd96d08cf38f941be4d3
Diffstat (limited to 'src/dir.cc')
-rw-r--r--src/dir.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/dir.cc b/src/dir.cc
index 14bc6ac4..1817e1d3 100644
--- a/src/dir.cc
+++ b/src/dir.cc
@@ -116,16 +116,18 @@ bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precomp
entries.clear();
return false;
}
- if (n == 0) break;
for (int pos = 0; pos < n;) {
auto* ent = reinterpret_cast<linux_dirent64*>(buf + pos);
if (!Dots(ent->d_name)) entries.push_back(ent->d_name);
pos += ent->d_reclen;
- // It's tempting to bail here if n + sizeof(linux_dirent64) + 512 <= n. After all, there
- // was enough space for another entry but SYS_getdents64 didn't write it, so this must be
- // the end of the directory listing, right? Unfortuatenly, no. SYS_getdents64 is finicky.
- // It sometimes writes a partial list of entries even if the full list would fit.
}
+ if (n == 0) break;
+ // The following optimization relies on SYS_getdents64 always returning as many
+ // entries as would fit. This is not guaranteed by the specification and I don't
+ // know if this is true in practice. The optimization has no measurable effect on
+ // gitstatus performance, so it's turned off.
+ //
+ // if (n + sizeof(linux_dirent64) + 512 <= kBufSize) break;
}
if (case_sensitive) {