Skip to content

Commit f9f6e41

Browse files
committed
chore: remove redundant for in GetFilesList
1 parent 63d816b commit f9f6e41

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/legacy/api/FileSystemAPI.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ Local<Value> FileClass::write(const Arguments& args) {
343343
data = std::move(args[0].asString().toString());
344344
} else if (args[0].isByteBuffer()) {
345345
isString = false;
346-
data =
347-
std::move(std::string((char*)args[0].asByteBuffer().getRawBytes(), args[0].asByteBuffer().byteLength())
348-
);
346+
data = std::move(
347+
std::string((char*)args[0].asByteBuffer().getRawBytes(), args[0].asByteBuffer().byteLength())
348+
);
349349
} else {
350350
LOG_WRONG_ARG_TYPE(__FUNCTION__);
351351
return {};
@@ -641,14 +641,12 @@ Local<Value> GetFilesList(const Arguments& args) {
641641
std::filesystem::directory_entry directory(args[0].asString().toU8string());
642642
if (!directory.is_directory()) return {};
643643

644-
std::vector<std::string> fileList;
644+
Local<Array> arr = Array::newArray();
645645
std::filesystem::directory_iterator deps(directory);
646646
for (auto& i : deps) {
647-
fileList.push_back(ll::string_utils::u8str2str(i.path().filename().u8string()));
647+
arr.add(String::newString(ll::string_utils::u8str2str(i.path().filename().u8string())));
648648
}
649649

650-
Local<Array> arr = Array::newArray();
651-
for (auto& file : fileList) arr.add(String::newString(file));
652650
return arr;
653651
}
654652
CATCH("Fail in GetFilesList!");

0 commit comments

Comments
 (0)