mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-29 15:23:02 +05:00
Removed some duplicate code in Patternies
Perfect forwarding for for_each_result functor
This commit is contained in:
parent
49796ff0cf
commit
1f800587f1
1 changed files with 11 additions and 31 deletions
|
@ -77,7 +77,7 @@ namespace hook
|
|||
|
||||
std::vector<pattern_match> m_matches;
|
||||
|
||||
bool m_matched;
|
||||
bool m_matched = false;
|
||||
|
||||
union
|
||||
{
|
||||
|
@ -91,12 +91,12 @@ namespace hook
|
|||
|
||||
protected:
|
||||
inline pattern(void* module)
|
||||
: m_module(module), m_rangeEnd(0), m_matched(false)
|
||||
: m_module(module), m_rangeEnd(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline pattern(uintptr_t begin, uintptr_t end)
|
||||
: m_rangeStart(begin), m_rangeEnd(end), m_matched(false)
|
||||
: m_rangeStart(begin), m_rangeEnd(end)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -120,44 +120,24 @@ namespace hook
|
|||
Initialize(pattern, Len-1);
|
||||
}
|
||||
|
||||
inline pattern& count(uint32_t expected) &
|
||||
inline pattern&& count(uint32_t expected)
|
||||
{
|
||||
EnsureMatches(expected);
|
||||
assert(m_matches.size() == expected);
|
||||
return *this;
|
||||
return std::forward<pattern>(*this);
|
||||
}
|
||||
|
||||
inline pattern& count_hint(uint32_t expected) &
|
||||
inline pattern&& count_hint(uint32_t expected)
|
||||
{
|
||||
EnsureMatches(expected);
|
||||
return *this;
|
||||
return std::forward<pattern>(*this);
|
||||
}
|
||||
|
||||
inline pattern& clear() &
|
||||
inline pattern&& clear()
|
||||
{
|
||||
m_matches.clear();
|
||||
m_matched = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline pattern&& count(uint32_t expected) &&
|
||||
{
|
||||
EnsureMatches(expected);
|
||||
assert(m_matches.size() == expected);
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
inline pattern&& count_hint(uint32_t expected) &&
|
||||
{
|
||||
EnsureMatches(expected);
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
inline pattern&& clear() &&
|
||||
{
|
||||
m_matches.clear();
|
||||
m_matched = false;
|
||||
return std::move(*this);
|
||||
return std::forward<pattern>(*this);
|
||||
}
|
||||
|
||||
inline size_t size()
|
||||
|
@ -189,12 +169,12 @@ namespace hook
|
|||
}
|
||||
|
||||
template <typename Pred>
|
||||
inline void for_each_result(Pred pred)
|
||||
inline void for_each_result(Pred&& pred)
|
||||
{
|
||||
EnsureMatches(UINT32_MAX);
|
||||
for ( auto it : m_matches )
|
||||
{
|
||||
pred(it);
|
||||
std::forward<Pred>(pred)(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue