[Lldb-commits] [PATCH] D139083: [lldb][Module][NFC] Add ModuleList::AnyOf
Michael Buch via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 1 13:02:36 PST 2022
Michael137 added a comment.
In D139083#3964612 <https://reviews.llvm.org/D139083#3964612>, @aprantl wrote:
> This is definitely useful — I just have one question: Isn't ForEach a special case of AnyOf? Could we implement on in terms of the other?
Yup it is. But it looked a bit too clever and just iterating over `m_modules` seemed cleaner.
bool ret = false;
ForEach([&](auto const& module) {
if (callback(module)) {
ret = true;
return false;
}
return true;
}
return ret;
It looked a bit awkward
================
Comment at: lldb/include/lldb/Core/ModuleList.h:480
+ /// This function is thread-safe.
+ bool AnyOf(std::function<bool(const lldb::ModuleSP &module_sp)> const
+ &callback) const;
----------------
Michael137 wrote:
> aprantl wrote:
> > Why not `std::function<bool(const lldb::Module &)>` ?
> Unfortunately a lot of APIs of `Module` are non-const since they rely on updating internal state :(
Re. why shared_ptr, that's because I just waned to align it with `ForEach`. I suppose if we're starting fresh we could just pass the reference. It would have to be mutable though
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139083/new/
https://reviews.llvm.org/D139083
More information about the lldb-commits
mailing list