From 2147aa435a89e96c2d9ee499367c6d5891100432 Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Sun, 3 Nov 2024 19:27:00 -0800 Subject: [PATCH] NotesLoader::GetMainAndSubTitlesFromFullTitle Minor cleanup on `GetMainAndSubTitlesFromFullTitle` to use a range-based for loop, and also is slightly improved so that separators of any length will work, whereas the original code only works when the separator is one character long. --- src/NotesLoader.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/NotesLoader.cpp b/src/NotesLoader.cpp index 3361da0363..27e88e951c 100644 --- a/src/NotesLoader.cpp +++ b/src/NotesLoader.cpp @@ -11,23 +11,24 @@ #include #include - void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut ) { - const RString sLeftSeps[] = { "\t", " -", " ~", " (", " [" }; + static const std::string_view sLeftSeps[] = { "\t", " -", " ~", " (", " [" }; + size_t fullTitleSize = sFullTitle.size(); - for( unsigned i=0; i(iBeginIndex)); + sSubTitleOut = sFullTitle.substr(iBeginIndex + sep.size(), fullTitleSize - iBeginIndex - sep.size()); + return; + } } sMainTitleOut = sFullTitle; sSubTitleOut = ""; -}; +} bool NotesLoader::LoadFromDir( const RString &sPath, Song &out, std::set &BlacklistedImages, bool load_autosave ) {