This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFCI] Module constructor should take ConstString by value
ClosedPublic

Authored by bulbazord on Aug 15 2023, 6:08 PM.

Details

Summary

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.

Diff Detail

Event Timeline

bulbazord created this revision.Aug 15 2023, 6:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2023, 6:08 PM
bulbazord requested review of this revision.Aug 15 2023, 6:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2023, 6:08 PM
aprantl added inline comments.Aug 16 2023, 8:54 AM
lldb/include/lldb/Core/Module.h
127

If we're passing it by value, why the const qualifier?

lldb/source/Core/Module.cpp
248–249

why not m_object_name(object_name) above?

Addressing @aprantl's feedback

bulbazord marked 2 inline comments as done.Aug 16 2023, 11:11 AM
mib added inline comments.Aug 16 2023, 11:11 AM
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
806 ↗(On Diff #550812)

Can this be {} ?

lldb/source/Target/Process.cpp
2389 ↗(On Diff #550812)

Should the module constructor have this as a default value for the ConstString parameter ?

fdeazeve added inline comments.
lldb/include/lldb/Core/Module.h
126–127

Out of curiosity, what was the rationale for removing the default parameter here?

bulbazord added inline comments.Aug 16 2023, 11:18 AM
lldb/include/lldb/Core/Module.h
126–127

I didn't really even think about it, I probably should have just done ConstString object_name = ConstString() or something.

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
806 ↗(On Diff #550812)

Yes, although I'll probably make the default value of the parameter be an empty ConstString instead.

Give the parameter a default value

bulbazord marked an inline comment as done.Aug 16 2023, 11:23 AM

Remove const from parameter in DebugMapModule

fdeazeve accepted this revision.Aug 16 2023, 11:28 AM

LGTM! Good catch :)

This revision is now accepted and ready to land.Aug 16 2023, 11:28 AM
mib accepted this revision.Aug 16 2023, 11:33 AM

LGTM!

aprantl accepted this revision.Aug 16 2023, 1:31 PM