From c8f3fc9a4b7060d78b8bd2cdaf4b7b0b93cc4d05 Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 18 Jul 2018 00:12:39 -0400
Subject: [PATCH 1/2] 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.
---
 src/yuzu/game_list.cpp | 8 +++++---
 src/yuzu/game_list.h   | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 5a708dc73b..fffa57ce10 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -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
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index 7aff597b77..bf8486b54c 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -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;

From f4b98a857b7e4e1b54670d8a86c2937b6030d9cf Mon Sep 17 00:00:00 2001
From: Lioncash <mathew1800@gmail.com>
Date: Wed, 18 Jul 2018 00:15:46 -0400
Subject: [PATCH 2/2] game_list: Upper-case containsAllWords to
 ContainsAllWords()

This makes it consistent with most of the other private utility
functions.
---
 src/yuzu/game_list.cpp | 4 ++--
 src/yuzu/game_list.h   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index fffa57ce10..fae5be372a 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -141,7 +141,7 @@ 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(const QString& haystack, const QString& userinput) const {
+bool GameList::ContainsAllWords(const QString& haystack, const QString& userinput) const {
     const QStringList userinput_split =
         userinput.split(' ', QString::SplitBehavior::SkipEmptyParts);
 
@@ -180,7 +180,7 @@ void GameList::onTextChanged(const QString& newText) {
             // The search is case insensitive because of toLower()
             // I decided not to use Qt::CaseInsensitive in containsAllWords to prevent
             // multiple conversions of edit_filter_text for each game in the gamelist
-            if (containsAllWords(file_name.append(" ").append(file_title), edit_filter_text) ||
+            if (ContainsAllWords(file_name.append(' ').append(file_title), edit_filter_text) ||
                 (file_programmid.count() == 16 && edit_filter_text.contains(file_programmid))) {
                 tree_view->setRowHidden(i, root_index, false);
                 ++result_count;
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index bf8486b54c..14db3956d0 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -89,7 +89,7 @@ private:
 
     void PopupContextMenu(const QPoint& menu_location);
     void RefreshGameDirectory();
-    bool containsAllWords(const QString& haystack, const QString& userinput) const;
+    bool ContainsAllWords(const QString& haystack, const QString& userinput) const;
 
     SearchField* search_field;
     GMainWindow* main_window = nullptr;