Use ReaddirCalc in all readdir implementations to avoid per-entry path construction

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Antonio S. Musumeci 2026-04-10 22:05:07 -04:00
parent 8af7effa98
commit afeaa60eb2
6 changed files with 18 additions and 36 deletions

View file

@ -43,7 +43,6 @@ _readdir(const fs::path &branch_path_,
{
int fd;
fuse_msgbuf_t *buf;
fs::path rel_filepath;
fs::path abs_dirpath;
abs_dirpath = branch_path_ / rel_dirpath_;
@ -56,7 +55,7 @@ _readdir(const fs::path &branch_path_,
buf = msgbuf_alloc();
DEFER{ msgbuf_free(buf); };
rel_filepath = rel_dirpath_ / "dummy";
fs::inode::ReaddirCalc inodecalc(branch_path_,rel_dirpath_);
while(true)
{
ssize_t nread;
@ -80,10 +79,8 @@ _readdir(const fs::path &branch_path_,
if(rv == 0)
continue;
rel_filepath.replace_filename(d->name);
d->ino = fs::inode::calc(branch_path_,
rel_filepath,
d->ino = inodecalc.calc(d->name,
namelen,
DTTOIF(d->type),
d->ino);

View file

@ -57,7 +57,6 @@ _readdir(const fs::path &branch_path_,
mutex_t &mutex_)
{
DIR *dir;
fs::path rel_filepath;
fs::path abs_dirpath;
abs_dirpath = branch_path_ / rel_dirpath_;
@ -68,7 +67,7 @@ _readdir(const fs::path &branch_path_,
return -errno;
DEFER{ fs::closedir(dir); };
rel_filepath = rel_dirpath_ / "dummy";
fs::inode::ReaddirCalc inodecalc(branch_path_,rel_dirpath_);
while(true)
{
LockGuard lk(mutex_);
@ -89,10 +88,8 @@ _readdir(const fs::path &branch_path_,
if(rv == 0)
continue;
rel_filepath.replace_filename(de->d_name);
de->d_ino = fs::inode::calc(branch_path_,
rel_filepath,
de->d_ino = inodecalc.calc(de->d_name,
namelen,
DTTOIF(de->d_type),
de->d_ino);

View file

@ -84,13 +84,11 @@ _readdir(std::vector<std::future<DirRV>> &dh_futures_,
{
Err err;
HashSet names;
fs::path rel_filepath;
fuse_msgbuf_t *buf;
buf = msgbuf_alloc();
DEFER { msgbuf_free(buf); };
rel_filepath = rel_dirpath_ / "dummy";
for(auto &dh_future : dh_futures_)
{
DirRV dirrv;
@ -101,6 +99,7 @@ _readdir(std::vector<std::future<DirRV>> &dh_futures_,
if(dirrv.fd < 0)
continue;
DEFER { fs::close(dirrv.fd); };
fs::inode::ReaddirCalc inodecalc(*dirrv.branch_path,rel_dirpath_);
while(true)
{
@ -124,10 +123,8 @@ _readdir(std::vector<std::future<DirRV>> &dh_futures_,
if(rv == 0)
continue;
rel_filepath.replace_filename(d->name);
d->ino = fs::inode::calc(*dirrv.branch_path,
rel_filepath,
d->ino = inodecalc.calc(d->name,
namelen,
DTTOIF(d->type),
d->ino);

View file

@ -94,9 +94,7 @@ _readdir(std::vector<std::future<DirRV>> &dh_futures_,
{
Err err;
HashSet names;
fs::path rel_filepath;
rel_filepath = rel_dirpath_ / "dummy";
for(auto &dh_future : dh_futures_)
{
DirRV dirrv;
@ -107,6 +105,7 @@ _readdir(std::vector<std::future<DirRV>> &dh_futures_,
if(dirrv.dir == NULL)
continue;
DEFER { fs::closedir(dirrv.dir); };
fs::inode::ReaddirCalc inodecalc(*dirrv.branch_path,rel_dirpath_);
for(dirent *de = fs::readdir(dirrv.dir);
de;
@ -121,10 +120,8 @@ _readdir(std::vector<std::future<DirRV>> &dh_futures_,
if(rv == 0)
continue;
rel_filepath.replace_filename(de->d_name);
de->d_ino = fs::inode::calc(*dirrv.branch_path,
rel_filepath,
de->d_ino = inodecalc.calc(de->d_name,
namelen,
DTTOIF(de->d_type),
de->d_ino);

View file

@ -39,7 +39,6 @@ _readdir(const Branches::Ptr &branches_,
{
Err err;
HashSet names;
fs::path rel_filepath;
fs::path abs_dirpath;
fuse_msgbuf_t *buf;
@ -48,10 +47,10 @@ _readdir(const Branches::Ptr &branches_,
buf = msgbuf_alloc();
DEFER { msgbuf_free(buf); };
rel_filepath = rel_dirpath_ / "dummy";
for(const auto &branch : *branches_)
{
int fd;
fs::inode::ReaddirCalc inodecalc(branch.path,rel_dirpath_);
abs_dirpath = branch.path / rel_dirpath_;
@ -83,10 +82,8 @@ _readdir(const Branches::Ptr &branches_,
if(rv == 0)
continue;
rel_filepath.replace_filename(d->name);
d->ino = fs::inode::calc(branch.path,
rel_filepath,
d->ino = inodecalc.calc(d->name,
namelen,
DTTOIF(d->type),
d->ino);

View file

@ -52,15 +52,14 @@ _readdir(const Branches::Ptr &branches_,
{
Err err;
HashSet names;
fs::path rel_filepath;
fs::path abs_dirpath;
fuse_dirents_reset(dirents_);
rel_filepath = rel_dirpath_ / "dummy";
for(const auto &branch : *branches_)
{
DIR *dh;
fs::inode::ReaddirCalc inodecalc(branch.path,rel_dirpath_);
abs_dirpath = branch.path / rel_dirpath_;
@ -84,10 +83,8 @@ _readdir(const Branches::Ptr &branches_,
if(rv == 0)
continue;
rel_filepath.replace_filename(de->d_name);
de->d_ino = fs::inode::calc(branch.path,
rel_filepath,
de->d_ino = inodecalc.calc(de->d_name,
namelen,
DTTOIF(de->d_type),
de->d_ino);