From dd20c11d8beaff5235ff1d8d68d66666c559abe5 Mon Sep 17 00:00:00 2001 From: suchmememanyskill <38142618+suchmememanyskill@users.noreply.github.com> Date: Tue, 23 Jan 2024 20:07:06 +0100 Subject: [PATCH] Slightly optimise file reader --- CYD-Klipper/src/core/files_query.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CYD-Klipper/src/core/files_query.cpp b/CYD-Klipper/src/core/files_query.cpp index 85acfa1..ff493b5 100644 --- a/CYD-Klipper/src/core/files_query.cpp +++ b/CYD-Klipper/src/core/files_query.cpp @@ -53,8 +53,10 @@ FILESYSTEM_FILE* get_files(int limit){ file_iter++; } + + if (file_iter == files.end() && files.size() >= limit) + continue; - // Little inefficient as it always allocates a string, even if it doesn't have to f.name = (char*)malloc(strlen(path) + 1); if (f.name == NULL){ Serial.println("Failed to allocate memory");