Use range based accumulate wrapper instead of std::accumulate

This commit is contained in:
Maxime Coste 2017-06-07 13:36:47 +01:00
parent a0d848da8d
commit b7982c6ee3
2 changed files with 6 additions and 6 deletions

View File

@ -159,9 +159,9 @@ InsertCompletion complete_word(const SelectionList& sels, const OptionManager& o
std::sort(matches.begin(), matches.end()); std::sort(matches.begin(), matches.end());
matches.erase(std::unique(matches.begin(), matches.end()), matches.end()); matches.erase(std::unique(matches.begin(), matches.end()), matches.end());
const auto longest = std::accumulate(matches.begin(), matches.end(), 0_char, const auto longest = accumulate(matches, 0_char,
[](const CharCount& lhs, const RankedMatchAndBuffer& rhs) [](const CharCount& lhs, const RankedMatchAndBuffer& rhs)
{ return std::max(lhs, rhs.candidate().char_length()); }); { return std::max(lhs, rhs.candidate().char_length()); });
InsertCompletion::CandidateList candidates; InsertCompletion::CandidateList candidates;
candidates.reserve(matches.size()); candidates.reserve(matches.size());

View File

@ -6,9 +6,9 @@ namespace Kakoune
StringDataPtr StringData::create(ArrayView<const StringView> strs) StringDataPtr StringData::create(ArrayView<const StringView> strs)
{ {
const int len = std::accumulate(strs.begin(), strs.end(), 0, const int len = accumulate(strs, 0, [](int l, StringView s) {
[](int l, StringView s) return l + (int)s.length();
{ return l + (int)s.length(); }); });
void* ptr = StringData::operator new(sizeof(StringData) + len + 1); void* ptr = StringData::operator new(sizeof(StringData) + len + 1);
auto* res = new (ptr) StringData(len); auto* res = new (ptr) StringData(len);
auto* data = reinterpret_cast<char*>(res + 1); auto* data = reinterpret_cast<char*>(res + 1);