diff --git a/CMakeLists.txt b/CMakeLists.txt index 28ccdf4..d7f9ee7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,15 @@ FetchContent_Declare( ) FetchContent_Populate(folly) +### range-v3 +FetchContent_Declare( + range-v3 + GIT_REPOSITORY https://github.com/ericniebler/range-v3.git + GIT_TAG a81477931a8aa2ad025c6bda0609f38e09e4d7ec # 0.12.0 + GIT_PROGRESS TRUE +) +FetchContent_MakeAvailable(range-v3) + set_project_warnings() if (ASAN) @@ -291,6 +300,7 @@ target_link_libraries(oicore ${Boost_LIBRARIES} Boost::headers glog::glog + range-v3 resources ) if (FORCE_LLVM_STATIC) diff --git a/oi/OICompiler.h b/oi/OICompiler.h index b08528c..2ce4544 100644 --- a/oi/OICompiler.h +++ b/oi/OICompiler.h @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -204,19 +206,9 @@ std::optional> OICompiler::locateOpcodes( std::vector locs; while (auto inst = DG()) { - auto it = std::find_if( - std::begin(needles), std::end(needles), [&](const auto& needle) { - // std::ranges::starts_with(inst->opcodes, needle) - if (std::ranges::size(needle) > std::ranges::size(inst->opcodes)) - return false; - auto it1 = std::ranges::begin(inst->opcodes); - auto it2 = std::ranges::begin(needle); - for (; it2 != std::ranges::end(needle); ++it1, ++it2) { - if (*it1 != *it2) - return false; - } - return true; - }); + auto it = ranges::find_if(needles, [&](const auto& needle) { + return ranges::starts_with(inst->opcodes, needle); + }); if (it != std::end(needles)) { locs.push_back(inst->offset); diff --git a/oi/type_graph/KeyCapture.cpp b/oi/type_graph/KeyCapture.cpp index 5e09020..e3f7d11 100644 --- a/oi/type_graph/KeyCapture.cpp +++ b/oi/type_graph/KeyCapture.cpp @@ -66,8 +66,7 @@ void KeyCapture::visit(Class& c) { continue; if (!keyToCapture.member.has_value()) continue; - for (size_t i = 0; i < c.members.size(); i++) { - auto& member = c.members[i]; + for (auto& member : c.members) { if (member.name != *keyToCapture.member) continue;