From 4f3bbf89c32b722f560bc4fc9c517716a7ab6992 Mon Sep 17 00:00:00 2001 From: Artyom Ivanov Date: Wed, 3 Jun 2026 15:35:55 +0300 Subject: [PATCH] refactor(path_utils): Reuse existing buffer on each `PosixDirIterator` iteration --- src/common/os/posix/path_utils.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/os/posix/path_utils.cpp b/src/common/os/posix/path_utils.cpp index 26f6476a8e5..ea2253b8e43 100644 --- a/src/common/os/posix/path_utils.cpp +++ b/src/common/os/posix/path_utils.cpp @@ -102,18 +102,18 @@ const PosixDirIterator& PosixDirIterator::operator++() { while ( (ent = os_utils::readdir(dir)) ) { - PathName entryname; - PathUtils::concatPath(entryname, dirPrefix, ent->d_name); + PathUtils::concatPath(file, dirPrefix, ent->d_name); struct stat stats; - if (!stat(entryname.c_str(), &stats) && S_ISREG(stats.st_mode)) + if (!stat(file.c_str(), &stats) && S_ISREG(stats.st_mode)) break; } - if (ent) - PathUtils::concatPath(file, dirPrefix, ent->d_name); - else + if (!ent) + { done = true; + file.clear(); + } } return *this;