Remove the isNPOS boolean and assign lastSlash to position1 when it isn't equal to string_view::npos

This commit is contained in:
Username404-59 2021-10-15 13:02:46 +02:00
parent cd8b14e00b
commit 7b8b8addd6
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 3 additions and 7 deletions

View File

@ -50,15 +50,11 @@ int main(int argc, char* argv[]) {
} catch (const Yerbacon::Exception& error) { } catch (const Yerbacon::Exception& error) {
unsigned long lastSlash = 0; unsigned long lastSlash = 0;
const unsigned long position1 = fileName.find_last_of('/'); const unsigned long position1 = fileName.find_last_of('/');
const bool isNPOS = cmp_equal(position1, string_view::npos); if (cmp_not_equal(position1, string_view::npos)) lastSlash = position1;
if constexpr(filesystem::path::preferred_separator == '/') { if constexpr(filesystem::path::preferred_separator != '/') {
if (not isNPOS) {
lastSlash = position1;
}
} else {
const unsigned long position2 = fileName.find_last_of(filesystem::path::preferred_separator); const unsigned long position2 = fileName.find_last_of(filesystem::path::preferred_separator);
if (cmp_not_equal(position2, string_view::npos)) { if (cmp_not_equal(position2, string_view::npos)) {
lastSlash = (isNPOS) ? position2 : max(position1, position2); lastSlash = max(lastSlash, position2);
} }
} }
resultingPair.first = fileName.substr(lastSlash + 1); resultingPair.first = fileName.substr(lastSlash + 1);