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,7 +159,7 @@ InsertCompletion complete_word(const SelectionList& sels, const OptionManager& o
std::sort(matches.begin(), 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)
{ return std::max(lhs, rhs.candidate().char_length()); });

View File

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