Skip to content

Commit 88c0bf6

Browse files
committed
Avoid copying the entire module list (NFC).
This does the exact same amount of locking as the previous version, it's just slightly more efficient to use ForEach().
1 parent c625cfb commit 88c0bf6

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lldb/source/Target/SwiftLanguageRuntime.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,21 @@ static ModuleSP findRuntime(Process &process, RuntimeKind runtime_kind) {
107107
return {};
108108
}
109109

110-
ModuleList images = process.GetTarget().GetImages();
111-
for (unsigned i = 0, e = images.GetSize(); i < e; ++i) {
112-
ModuleSP image = images.GetModuleAtIndex(i);
113-
if (!image)
114-
continue;
115-
if (runtime_kind == RuntimeKind::Swift &&
116-
IsModuleSwiftRuntime(process, *image))
117-
return image;
110+
ModuleSP runtime_image;
111+
process.GetTarget().GetImages().ForEach([&](const ModuleSP &image) {
112+
if (runtime_kind == RuntimeKind::Swift && image &&
113+
IsModuleSwiftRuntime(process, *image)) {
114+
runtime_image = image;
115+
return false;
116+
}
118117
if (runtime_kind == RuntimeKind::ObjC &&
119-
objc_runtime->IsModuleObjCLibrary(image))
120-
return image;
121-
}
122-
return {};
118+
objc_runtime->IsModuleObjCLibrary(image)) {
119+
runtime_image = image;
120+
return false;
121+
}
122+
return true;
123+
});
124+
return runtime_image;
123125
}
124126

125127
static llvm::Optional<lldb::addr_t>

0 commit comments

Comments
 (0)