From d9a66e59d5013ee11d29129e68a88f5da0b8d1c1 Mon Sep 17 00:00:00 2001 From: Davide Mor <davide.mor@skywarder.eu> Date: Tue, 2 Apr 2024 21:47:32 +0200 Subject: [PATCH] [PrintLogger] Replaced rfind with find_last_of --- src/shared/diagnostic/PrintLogger.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/shared/diagnostic/PrintLogger.cpp b/src/shared/diagnostic/PrintLogger.cpp index 6ede9aaf1..0e23b4cee 100644 --- a/src/shared/diagnostic/PrintLogger.cpp +++ b/src/shared/diagnostic/PrintLogger.cpp @@ -48,21 +48,13 @@ static string getLevelString(uint8_t level) static string truncateFileName(const string& name, int depth = 0) { - char sep = '/'; - - // Find the first separator if there is one - auto start = name.rfind(sep); - if (start == string::npos) - { - // Maybe we are on windows... - sep = '\\'; - start = name.rfind(sep); - } + // Find the first separator + auto start = name.find_last_of("\\/"); // Now traverse the path until we reach the end or the required depth for (int i = 0; i < depth && start != string::npos; i++) { - start = name.rfind(sep, start - 1); + start = name.find_last_of("\\/", start - 1); } // Truncate the path if needed -- GitLab