Skip to content

Commit

Permalink
Use ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Oct 5, 2024
1 parent 7b2b461 commit a8a5302
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
UseColor: true
WarningsAsErrors: true,*
HeaderFilterRegex: "src/"
Checks: '-*,bugprone-*,-bugprone-branch-clone,-bugprone-easily-swappable-parameters,-bugprone-exception-escape,-bugprone-unchecked-optional-access,-bugprone-crtp-constructor-accessibility,cert-*,-cert-err58-cpp,-cert-env33-c,clang-analyzer-*,concurrency-*,-concurrency-mt-unsafe,cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,google-*,-google-readability-todo,misc-*,-misc-include-cleaner,-misc-no-recursion,-misc-use-anonymous-namespace,modernize-*,-misc-use-internal-linkage,-modernize-use-nodiscard,-modernize-use-trailing-return-type,-modernize-use-ranges,performance-*,portability-*,readability-*,-readability-else-after-return,-readability-implicit-bool-conversion,-readability-identifier-length,-readability-function-cognitive-complexity'
Checks: '-*,bugprone-*,-bugprone-branch-clone,-bugprone-easily-swappable-parameters,-bugprone-exception-escape,-bugprone-unchecked-optional-access,-bugprone-crtp-constructor-accessibility,cert-*,-cert-err58-cpp,-cert-env33-c,clang-analyzer-*,concurrency-*,-concurrency-mt-unsafe,cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,google-*,-google-readability-todo,misc-*,-misc-include-cleaner,-misc-no-recursion,-misc-use-anonymous-namespace,modernize-*,-misc-use-internal-linkage,-modernize-use-nodiscard,-modernize-use-trailing-return-type,performance-*,portability-*,readability-*,-readability-else-after-return,-readability-implicit-bool-conversion,-readability-identifier-length,-readability-function-cognitive-complexity'
CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: true
Expand Down
8 changes: 4 additions & 4 deletions src/Algos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cctype>
#include <memory>
#include <optional>
#include <ranges>
#include <string>
#include <string_view>
#include <thread>
Expand Down Expand Up @@ -136,10 +137,9 @@ static bool
equalsInsensitive(
const std::string_view lhs, const std::string_view rhs
) noexcept {
return std::equal(
lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend(),
[](char lhs, char rhs) { return std::tolower(lhs) == std::tolower(rhs); }
);
return std::ranges::equal(lhs, rhs, [](char lhs, char rhs) {
return std::tolower(lhs) == std::tolower(rhs);
});
}

std::optional<std::string_view>
Expand Down
5 changes: 3 additions & 2 deletions src/Cmd/Fmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <ranges>
#include <span>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -45,8 +46,8 @@ collectFormatTargetFiles(
}

const auto isExcluded = [&](std::string_view path) -> bool {
return std::find_if(
excludes.begin(), excludes.end(),
return std::ranges::find_if(
excludes,
[&](const fs::path& path2) {
return fs::relative(path2, manifestDir).string() == path;
}
Expand Down

0 comments on commit a8a5302

Please sign in to comment.