Skip to content

Commit 9e6d48e

Browse files
committed
[lldb][NFCI] Module constructor should take ConstString by value
ConstStrings are super cheap to copy around. It is often more expensive to pass a pointer and potentially dereference it than just to always copy it. Differential Revision: https://reviews.llvm.org/D158043
1 parent 90c5675 commit 9e6d48e

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

lldb/include/lldb/Core/Module.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ class Module : public std::enable_shared_from_this<Module>,
124124
/// multiple architectures).
125125
Module(
126126
const FileSpec &file_spec, const ArchSpec &arch,
127-
const ConstString *object_name = nullptr,
128-
lldb::offset_t object_offset = 0,
127+
ConstString object_name = ConstString(), lldb::offset_t object_offset = 0,
129128
const llvm::sys::TimePoint<> &object_mod_time = llvm::sys::TimePoint<>());
130129

131130
Module(const ModuleSpec &module_spec);

lldb/source/Core/Module.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,22 +233,19 @@ Module::Module(const ModuleSpec &module_spec)
233233
}
234234

235235
Module::Module(const FileSpec &file_spec, const ArchSpec &arch,
236-
const ConstString *object_name, lldb::offset_t object_offset,
236+
ConstString object_name, lldb::offset_t object_offset,
237237
const llvm::sys::TimePoint<> &object_mod_time)
238238
: m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)),
239-
m_arch(arch), m_file(file_spec), m_object_offset(object_offset),
240-
m_object_mod_time(object_mod_time), m_file_has_changed(false),
241-
m_first_file_changed_log(false) {
239+
m_arch(arch), m_file(file_spec), m_object_name(object_name),
240+
m_object_offset(object_offset), m_object_mod_time(object_mod_time),
241+
m_file_has_changed(false), m_first_file_changed_log(false) {
242242
// Scope for locker below...
243243
{
244244
std::lock_guard<std::recursive_mutex> guard(
245245
GetAllocationModuleCollectionMutex());
246246
GetModuleCollection().push_back(this);
247247
}
248248

249-
if (object_name)
250-
m_object_name = *object_name;
251-
252249
Log *log(GetLog(LLDBLog::Object | LLDBLog::Modules));
253250
if (log != nullptr)
254251
LLDB_LOGF(log, "%p Module::Module((%s) '%s%s%s%s')",

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class DebugMapModule : public Module {
170170
public:
171171
DebugMapModule(const ModuleSP &exe_module_sp, uint32_t cu_idx,
172172
const FileSpec &file_spec, const ArchSpec &arch,
173-
const ConstString *object_name, off_t object_offset,
173+
ConstString object_name, off_t object_offset,
174174
const llvm::sys::TimePoint<> object_mod_time)
175175
: Module(file_spec, arch, object_name, object_offset, object_mod_time),
176176
m_exe_module_wp(exe_module_sp), m_cu_idx(cu_idx) {}
@@ -459,7 +459,7 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
459459
.c_str());
460460
comp_unit_info->oso_sp->module_sp = std::make_shared<DebugMapModule>(
461461
obj_file->GetModule(), GetCompUnitInfoIndex(comp_unit_info), oso_file,
462-
oso_arch, oso_object ? &oso_object : nullptr, 0,
462+
oso_arch, oso_object, 0,
463463
oso_object ? comp_unit_info->oso_mod_time : llvm::sys::TimePoint<>());
464464

465465
if (oso_object && !comp_unit_info->oso_sp->module_sp->GetObjectFile() &&

0 commit comments

Comments
 (0)