Skip to content

Commit

Permalink
More ranges (less trivial cases)
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Dec 9, 2023
1 parent 7378509 commit d551575
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion far/codepage_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ size_t codepages::GetCodePageInsertPosition(uintptr_t codePage, size_t start, si
};

const auto iRange = irange(start, start + length);
const auto Pos = std::find_if(CONST_RANGE(iRange, i) { return GetCodePage(i) >= codePage; });
const auto Pos = std::ranges::find_if(iRange, [&](size_t const i){ return GetCodePage(i) >= codePage; });
return Pos != iRange.cend()? *Pos : start + length;
}

Expand Down
2 changes: 1 addition & 1 deletion far/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,7 @@ bool Options::AdvancedConfig(config_type Mode)
items.reserve(CurrentConfig.size());
std::vector<string> Strings(CurrentConfig.size());
const auto ConfigData = zip(CurrentConfig, Strings);
std::transform(ALL_CONST_RANGE(ConfigData), std::back_inserter(items), [](const auto& i) { return std::get<0>(i).MakeListItem(std::get<1>(i)); });
std::ranges::transform(ConfigData, std::back_inserter(items), [](const auto& i) { return std::get<0>(i).MakeListItem(std::get<1>(i)); });

FarList Items{ sizeof(Items), items.size(), items.data() };

Expand Down
4 changes: 2 additions & 2 deletions far/encoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@ TEST_CASE("encoding.ucs2-utf8.round-trip")

const irange Chars(std::numeric_limits<wchar_t>::max() + 1);

const auto AllValid = std::all_of(ALL_CONST_RANGE(Chars), [&](wchar_t const Char)
const auto AllValid = std::ranges::all_of(Chars, [&](wchar_t const Char)
{
const auto Result = round_trip(Char);

Expand Down Expand Up @@ -1783,7 +1783,7 @@ TEST_CASE("encoding.utf8-ucs2.round-trip")

const irange Bytes(std::numeric_limits<char>::max() + 1);

const auto AllValid = std::all_of(ALL_CONST_RANGE(Bytes), [&](char const Byte)
const auto AllValid = std::ranges::all_of(Bytes, [&](char const Byte)
{
if (!(Byte & 0b10000000) || utf8::support_embedded_raw_bytes)
{
Expand Down
4 changes: 2 additions & 2 deletions far/findfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void background_searcher::InitInFileSearch()
{
// Проверяем наличие выбранных страниц символов
const auto CpEnum = codepages::GetFavoritesEnumerator();
const auto hasSelected = std::any_of(CONST_RANGE(CpEnum, i) { return i.second & CPST_FIND; });
const auto hasSelected = std::ranges::any_of(CpEnum, [](auto const& i){ return (i.second & CPST_FIND) != 0; });

if (hasSelected)
{
Expand Down Expand Up @@ -710,7 +710,7 @@ intptr_t FindFiles::MainDlgProc(Dialog* Dlg, intptr_t Msg, intptr_t Param1, void
{
const int TitlePosition = 1;
const auto CpEnum = codepages::GetFavoritesEnumerator();
const auto Title = msg(std::any_of(CONST_RANGE(CpEnum, i) { return i.second & CPST_FIND; })? lng::MFindFileSelectedCodePages : lng::MFindFileAllCodePages);
const auto Title = msg(std::ranges::any_of(CpEnum, [](auto const& i){ return i.second & CPST_FIND; })? lng::MFindFileSelectedCodePages : lng::MFindFileAllCodePages);
Dlg->GetAllItem()[FAD_COMBOBOX_CP].ListPtr->at(TitlePosition).Name = Title;
FarListPos Position{ sizeof(Position) };
Dlg->SendMessage(DM_LISTGETCURPOS, FAD_COMBOBOX_CP, &Position);
Expand Down
4 changes: 2 additions & 2 deletions far/string_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,14 @@ string_view detail::fuzzy_searcher_impl::normalize(string_view const Str)
}

zip const Zip(m_Result, m_Types);
const auto End = std::remove_if(ALL_RANGE(Zip), [](const auto& i)
const auto Removed = std::ranges::remove_if(Zip, [](const auto& i)
{
return
!flags::check_any(std::get<1>(i), C3_ALPHA | C3_LEXICAL) &&
flags::check_any(std::get<1>(i), C3_NONSPACING | C3_DIACRITIC | C3_VOWELMARK);
});

m_Result.resize(End - Zip.begin());
m_Result.resize(m_Result.size() - Removed.size());
return m_Result;
}

Expand Down

0 comments on commit d551575

Please sign in to comment.