Optimize some startup code related to about:flags handling.

Previously, the code would create a set from all the known
flags and compare the specified flags against them.

But actually this is less efficient than just the O(n*m) search,
because n being the number of flags set by the user and m being
the number of available flags, since n will likely be small or 0
and then we don't need to do a lot of work. In particular, this
also avoids copying a bunch of strings.

Bug: 904575
Change-Id: I63e59d439c432338aea71eb6258e8f8b42f04921
Reviewed-on: https://chromium-review.googlesource.com/c/1334413
Commit-Queue: Alexei Svitkine <[email protected]>
Reviewed-by: ssid <[email protected]>
Cr-Commit-Position: refs/heads/master@{#608128}
diff --git a/components/flags_ui/flags_state.h b/components/flags_ui/flags_state.h
index 21ad59df5..6ce8321 100644
--- a/components/flags_ui/flags_state.h
+++ b/components/flags_ui/flags_state.h
@@ -176,10 +176,15 @@
       bool feature_state,
       base::CommandLine* command_line);
 
-  // Removes all entries from prefs::kEnabledLabsExperiments that are unknown,
-  // to prevent this list to become very long as entries are added and removed.
-  void SanitizeList(FlagsStorage* flags_storage) const;
+  // Sanitizes |enabled_entries| to only contain entries that are defined in the
+  // |feature_entries_| and whose |supported_platforms| matches |platform_mask|.
+  // Pass -1 to |platform_mask| to not do platform filtering.
+  std::set<std::string> SanitizeList(
+      const std::set<std::string>& enabled_entries,
+      int platform_mask) const;
 
+  // Gets sanitized entries from |flags_storage|, filtering out any entries that
+  // don't exist in |feature_entries_|, and updates |flags_storage|.
   void GetSanitizedEnabledFlags(FlagsStorage* flags_storage,
                                 std::set<std::string>* result) const;