Skip to content

Commit

Permalink
Algos: remove unused toUpper (#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui authored Jan 31, 2025
1 parent bbf1096 commit e880e72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
9 changes: 0 additions & 9 deletions src/Algos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@

namespace cabin {

std::string
toUpper(const std::string_view str) noexcept {
std::string res;
for (const unsigned char c : str) {
res += static_cast<char>(std::toupper(c));
}
return res;
}

std::string
toMacroName(const std::string_view name) noexcept {
std::string macroName;
Expand Down
11 changes: 5 additions & 6 deletions src/Algos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace cabin {

std::string toUpper(std::string_view str) noexcept;
std::string toMacroName(std::string_view name) noexcept;
std::string replaceAll(
std::string str, std::string_view from, std::string_view to
Expand All @@ -24,6 +23,11 @@ Result<std::string>
getCmdOutput(const Command& cmd, std::size_t retry = 3) noexcept;
bool commandExists(std::string_view cmd) noexcept;

constexpr char
toLower(char c) noexcept {
return (c >= 'A' && c <= 'Z') ? static_cast<char>(c + ('a' - 'A')) : c;
}

// ref: https://wandbox.org/permlink/zRjT41alOHdwcf00
constexpr std::size_t
levDistance(const std::string_view lhs, const std::string_view rhs) noexcept {
Expand Down Expand Up @@ -63,11 +67,6 @@ levDistance(const std::string_view lhs, const std::string_view rhs) noexcept {
return dist[lhsSize][rhsSize];
}

constexpr char
toLower(char c) noexcept {
return (c >= 'A' && c <= 'Z') ? static_cast<char>(c + ('a' - 'A')) : c;
}

constexpr bool
equalsInsensitive(
const std::string_view lhs, const std::string_view rhs
Expand Down

0 comments on commit e880e72

Please sign in to comment.