This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Take StringRef name in GetChildMemberWithName (NFC)
ClosedPublic

Authored by kastiglione on May 27 2023, 11:16 AM.

Details

Summary

GetChildMemberWithName does not need a ConstString. This change makes the function
take a StringRef instead, which alleviates the need for callers to construct a
ConstString. I don't expect this change to improve performance, only ergonomics.

This is in support of Alex's effort to replace ConstString where appropriate.

There are related ValueObject functions that can also be changed, if this is accepted.

Diff Detail

Event Timeline

kastiglione created this revision.May 27 2023, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2023, 11:16 AM
kastiglione requested review of this revision.May 27 2023, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2023, 11:16 AM
bulbazord accepted this revision.May 27 2023, 8:08 PM

After reading though the code and thinking about it, I believe this change is appropriate. It may or may not have a measurable impact on performance, but my bet is that it doesn't make it worse. I suppose you could stress test the C++ formatters if you really wanted to know though. Either way, thank you for doing this work!

We should probably change CompilerType::GetIndexOfChildMemberWithName to take a StringRef instead of a const char * as a follow-up. You're having to call str() and then getting the const char * out of that to correctly call the function which is the right thing to do but is also a little wasteful.

This revision is now accepted and ready to land.May 27 2023, 8:08 PM

It may or may not have a measurable impact on performance, but my bet is that it doesn't make it worse.

yes the reason I wanted this change is for ergonomics, I was annoyed that it required a ConstString when internally it needs only a null terminated string. Eliminating these ConstStrings won't have perf savings, but it won't have a perf cost either.

I suppose you could stress test the C++ formatters if you really wanted to know though. Either way, thank you for doing this work!

Do you have something in mind? I figured the test suite was enough. Do you mean stress for perf, or for ensuring this change has no behavior regressions?

We should probably change CompilerType::GetIndexOfChildMemberWithName to take a StringRef instead of a const char * as a follow-up.

I made the same observation. I figured this change was big enough and was also a single semantic change, so I didn't scope it out any further.

bulbazord added a comment.EditedMay 28 2023, 12:28 PM

Do you have something in mind? I figured the test suite was enough. Do you mean stress for perf, or for ensuring this change has no behavior regressions?

I meant stress test for perf. Behavior-wise I think the test suite should catch anything major. I'd be surprised if this changed behavior since you're passing the same data around but in a different form.
I don't have anything in mind however. Should be fine without it.

I made the same observation. I figured this change was big enough and was also a single semantic change, so I didn't scope it out any further.

Sounds good.

kastiglione retitled this revision from [lldb] Change GetChildMemberWithName to take a StringRef, not ConstString to [lldb] Take StringRef name in GetChildMemberWithName (NFC).May 31 2023, 8:08 AM