Skip to content

Commit 348f3a0

Browse files
author
Hana Dusíková
committed
remove lambda and use force inlined function
1 parent a85f36d commit 348f3a0

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

include/ctre/evaluation.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ template <typename Iterator> struct string_match_result {
138138
bool match;
139139
};
140140

141+
template <typename CharT, typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE bool compare_character(CharT c, Iterator & it, const EndIterator & end) {
142+
bool same = ((it != end) && (*it == c));
143+
++it;
144+
return same;
145+
}
146+
141147
template <auto... String, size_t... Idx, typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE string_match_result<Iterator> evaluate_match_string(Iterator current, const EndIterator end, std::index_sequence<Idx...>) noexcept {
142148

143-
[[maybe_unused]] auto compare = [&](auto c) {
144-
bool same = ((current != end) && (*current == c));
145-
++current;
146-
return same;
147-
};
148-
149-
bool same = (compare(String) && ... && true);
149+
bool same = (compare_character(String, current, end) && ... && true);
150150

151151
return {current, same};
152152
}

single-header/ctre-unicode.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3857,15 +3857,15 @@ template <typename Iterator> struct string_match_result {
38573857
bool match;
38583858
};
38593859

3860+
template <typename CharT, typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE bool compare_character(CharT c, Iterator & it, const EndIterator & end) {
3861+
bool same = ((it != end) && (*it == c));
3862+
++it;
3863+
return same;
3864+
}
3865+
38603866
template <auto... String, size_t... Idx, typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE string_match_result<Iterator> evaluate_match_string(Iterator current, const EndIterator end, std::index_sequence<Idx...>) noexcept {
38613867

3862-
[[maybe_unused]] auto compare = [&](auto c) {
3863-
bool same = ((current != end) && (*current == c));
3864-
++current;
3865-
return same;
3866-
};
3867-
3868-
bool same = (compare(String) && ... && true);
3868+
bool same = (compare_character(String, current, end) && ... && true);
38693869

38703870
return {current, same};
38713871
}

single-header/ctre.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,15 +3854,15 @@ template <typename Iterator> struct string_match_result {
38543854
bool match;
38553855
};
38563856

3857+
template <typename CharT, typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE bool compare_character(CharT c, Iterator & it, const EndIterator & end) {
3858+
bool same = ((it != end) && (*it == c));
3859+
++it;
3860+
return same;
3861+
}
3862+
38573863
template <auto... String, size_t... Idx, typename Iterator, typename EndIterator> constexpr CTRE_FORCE_INLINE string_match_result<Iterator> evaluate_match_string(Iterator current, const EndIterator end, std::index_sequence<Idx...>) noexcept {
38583864

3859-
[[maybe_unused]] auto compare = [&](auto c) {
3860-
bool same = ((current != end) && (*current == c));
3861-
++current;
3862-
return same;
3863-
};
3864-
3865-
bool same = (compare(String) && ... && true);
3865+
bool same = (compare_character(String, current, end) && ... && true);
38663866

38673867
return {current, same};
38683868
}

0 commit comments

Comments
 (0)