Skip to content

Commit

Permalink
Replace memcmp by std::equal.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed May 20, 2024
1 parent b5d144a commit 8450bb3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ namespace ranges
return std::none_of(std::begin(range), std::end(range), std::forward<Predicate>(predicate));
}

template <typename Range>
bool equal(const Range &range1, const Range &range2)
{
return std::equal(std::begin(range1), std::end(range1), std::begin(range2), std::end(range2));
}


template <typename Range, typename Predicate>
std::size_t count_if(const Range &range, Predicate &&predicate)
{
Expand Down
5 changes: 2 additions & 3 deletions src/network/net_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,8 @@ void CServerSetup::Save(const std::function <void (std::string)>& f) {

bool CServerSetup::operator == (const CServerSetup &rhs) const
{
return (ServerGameSettings == rhs.ServerGameSettings
&& memcmp(CompOpt, rhs.CompOpt, sizeof(CompOpt)) == 0
&& memcmp(Ready, rhs.Ready, sizeof(Ready)) == 0);
return (ServerGameSettings == rhs.ServerGameSettings && ranges::equal(CompOpt, rhs.CompOpt)
&& ranges::equal(Ready, rhs.Ready));
}

//
Expand Down

0 comments on commit 8450bb3

Please sign in to comment.