mirror of
				https://git.zaroz.cloud/nintendo-back-up/yuzu/yuzu-mainline.git
				synced 2025-03-21 01:53:15 +00:00 
			
		
		
		
	game_list: Make containsAllWords a const member function
This doesn't actually modify the internal class state, so it can be a const member function. While we're at it, amend the function to take its arguments by const reference.
This commit is contained in:
		
							parent
							
								
									8e28af6f89
								
							
						
					
					
						commit
						c8f3fc9a4b
					
				@ -141,10 +141,12 @@ GameList::SearchField::SearchField(GameList* parent) : QWidget{parent} {
 | 
			
		||||
 * @param userinput String containing all words getting checked
 | 
			
		||||
 * @return true if the haystack contains all words of userinput
 | 
			
		||||
 */
 | 
			
		||||
bool GameList::containsAllWords(QString haystack, QString userinput) {
 | 
			
		||||
    QStringList userinput_split = userinput.split(" ", QString::SplitBehavior::SkipEmptyParts);
 | 
			
		||||
bool GameList::containsAllWords(const QString& haystack, const QString& userinput) const {
 | 
			
		||||
    const QStringList userinput_split =
 | 
			
		||||
        userinput.split(' ', QString::SplitBehavior::SkipEmptyParts);
 | 
			
		||||
 | 
			
		||||
    return std::all_of(userinput_split.begin(), userinput_split.end(),
 | 
			
		||||
                       [haystack](QString s) { return haystack.contains(s); });
 | 
			
		||||
                       [&haystack](const QString& s) { return haystack.contains(s); });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Event in order to filter the gamelist after editing the searchfield
 | 
			
		||||
 | 
			
		||||
@ -89,7 +89,7 @@ private:
 | 
			
		||||
 | 
			
		||||
    void PopupContextMenu(const QPoint& menu_location);
 | 
			
		||||
    void RefreshGameDirectory();
 | 
			
		||||
    bool containsAllWords(QString haystack, QString userinput);
 | 
			
		||||
    bool containsAllWords(const QString& haystack, const QString& userinput) const;
 | 
			
		||||
 | 
			
		||||
    SearchField* search_field;
 | 
			
		||||
    GMainWindow* main_window = nullptr;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user