]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Simplify code somewhat
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 9 Jul 2020 18:22:25 +0000 (20:22 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 9 Jul 2020 18:22:25 +0000 (20:22 +0200)
src/Context.cpp
src/ccache.cpp

index 654b098d5d37d3fe670532f3baaf67c5b5b2db39..578997269661904243e604fba25c12688bde4430 100644 (file)
@@ -127,7 +127,7 @@ void
 Context::set_ignore_options(const std::vector<std::string>& options)
 {
   for (const std::string& option : options) {
-    std::size_t n_wildcards = std::count(option.cbegin(), option.cend(), '*');
+    size_t n_wildcards = std::count(option.cbegin(), option.cend(), '*');
     if (n_wildcards == 0 || (n_wildcards == 1 && option.back() == '*')) {
       m_ignore_options.push_back(option);
     } else {
index 41cd21bd3210af9b3cd57dd0437531578142dee9..d120fddac9bd8989afcf24fbecd179ce1ae90b7b 100644 (file)
@@ -1377,15 +1377,15 @@ hash_profile_data_file(const Context& ctx, struct hash* hash)
 
 static bool
 option_should_be_ignored(const std::string& arg,
-                         const std::vector<std::string>& ignore_options)
+                         const std::vector<std::string>& patterns)
 {
-  auto pred = [&arg](const std::string& option) {
-    const auto& prefix = string_view(option).substr(0, option.length() - 1);
-    return (
-      option == arg
-      || (Util::ends_with(option, "*") && Util::starts_with(arg, prefix)));
-  };
-  return std::any_of(ignore_options.cbegin(), ignore_options.cend(), pred);
+  return std::any_of(
+    patterns.cbegin(), patterns.cend(), [&arg](const std::string& pattern) {
+      const auto& prefix = string_view(pattern).substr(0, pattern.length() - 1);
+      return (
+        pattern == arg
+        || (Util::ends_with(pattern, "*") && Util::starts_with(arg, prefix)));
+    });
 }
 
 // Update a hash sum with information specific to the direct and preprocessor