summaryrefslogtreecommitdiff
path: root/src/dir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dir.cpp')
-rw-r--r--src/dir.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/dir.cpp b/src/dir.cpp
index f502c45..b2de780 100644
--- a/src/dir.cpp
+++ b/src/dir.cpp
@@ -12,7 +12,8 @@
#include <types.h>
#include <utility>
-GitFS::Directory::Directory(Repo * const r, std::string && p) : repo(r), path(std::move(p)), subTreeCacheRootId({})
+GitFS::Directory::Directory(Repo * const repo, std::string path) :
+ repo(repo), path(std::move(path)), subTreeCacheRootId({})
{
getSubtree();
}
@@ -26,11 +27,11 @@ GitFS::Directory::getSubtree() const
subTreeCache = repo->tree;
}
else {
- auto e = Git::TreeEntryByPath(repo->tree, path);
- if (!S_ISDIR(git_tree_entry_filemode(e.get()))) {
+ auto entry = Git::treeEntryByPath(repo->tree, path);
+ if (!S_ISDIR(git_tree_entry_filemode(entry.get()))) {
throw NetFS::SystemError(ENOTDIR);
}
- subTreeCache = Git::TreeLookup(repo->repo, *git_tree_entry_id(e.get()));
+ subTreeCache = Git::treeLookup(repo->repo, *git_tree_entry_id(entry.get()));
}
subTreeCacheRootId = *git_tree_id(repo->tree.get());
}
@@ -38,9 +39,9 @@ GitFS::Directory::getSubtree() const
}
void
-GitFS::Directory::close(const ::Ice::Current & current)
+GitFS::Directory::close(const ::Ice::Current & ice)
{
- current.adapter->remove(current.id);
+ ice.adapter->remove(ice.id);
}
NetFS::NameList
@@ -48,9 +49,11 @@ GitFS::Directory::readdir(const ::Ice::Current &)
{
const auto subTree = getSubtree();
NetFS::NameList list;
- for (auto idx = git_tree_entrycount(subTree.get()); idx--;) {
+ auto idx = git_tree_entrycount(subTree.get());
+ list.reserve(idx);
+ while (idx--) {
const auto entry = git_tree_entry_byindex(subTree.get(), idx);
- list.push_back(git_tree_entry_name(entry));
+ list.emplace_back(git_tree_entry_name(entry));
}
return list;
}
@@ -62,15 +65,15 @@ GitFS::Directory::listdir(const ::Ice::Current &)
NetFS::DirectoryContents list;
for (auto idx = git_tree_entrycount(subTree.get()); idx--;) {
const auto entry = git_tree_entry_byindex(subTree.get(), idx);
- NetFS::Attr a {};
- a << *entry << *repo->commit;
+ NetFS::Attr attr {};
+ attr << *entry << *repo->commit;
if (S_ISREG(git_tree_entry_filemode(entry))) {
- auto blob = Git::BlobLookup(repo->repo, *git_tree_entry_id(entry));
- a << *blob;
+ auto blob = Git::blobLookup(repo->repo, *git_tree_entry_id(entry));
+ attr << *blob;
}
- a.gid = repo->gid;
- a.uid = repo->uid;
- list.emplace(git_tree_entry_name(entry), a);
+ attr.gid = repo->gid;
+ attr.uid = repo->uid;
+ list.emplace(git_tree_entry_name(entry), std::move(attr));
}
return list;
}