Skip to content

Commit

Permalink
refactor(linux/module): cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Jan 7, 2024
1 parent 6152644 commit 71dc5a6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/module.linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ namespace lime
{
std::vector<lime::symbol> rtn;

auto fn = [&](std::string_view name)
auto fn = [&](auto name)
{
auto sym = symbol(name);
auto str = std::string{name};

rtn.emplace_back(lime::symbol{
.name = str,
.name = std::move(str),
.address = sym,
});

Expand All @@ -78,7 +78,7 @@ namespace lime
{
std::uintptr_t rtn{0};

auto fn = [&](std::string_view item)
auto fn = [&](auto item)
{
if (item.find(name) == std::string_view::npos)
{
Expand Down Expand Up @@ -124,6 +124,7 @@ namespace lime
};

dl_iterate_phdr(callback, &rtn);

return rtn;
}

Expand Down Expand Up @@ -154,14 +155,18 @@ namespace lime
{
auto all = modules();

constexpr auto npos = std::string::npos;
auto module = std::find_if(all.begin(), all.end(), [&](auto &item) { return item.name().find(name) != npos; });
auto fn = [&](const auto &item)
{
return item.name().find(name) != std::string_view::npos;
};

auto rtn = std::ranges::find_if(all, fn);

if (module == all.end())
if (rtn == all.end())
{
return std::nullopt;
}

return std::move(*module);
return std::move(*rtn);
}
} // namespace lime

0 comments on commit 71dc5a6

Please sign in to comment.