This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy][NFC] IdentifierNaming: Remove unnecessary string allocations
ClosedPublic

Authored by njames93 on Oct 27 2020, 9:23 AM.

Details

Summary

Remove the need to heap allocate a string for each style option lookup while reading or writing options.p

Diff Detail

Event Timeline

njames93 created this revision.Oct 27 2020, 9:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2020, 9:23 AM
njames93 requested review of this revision.Oct 27 2020, 9:23 AM

Was this caused by a performance concern when profiling something? I'm not opposed to the changes, but I do think the original formulation is easier to read.

Was this caused by a performance concern when profiling something? I'm not opposed to the changes, but I do think the original formulation is easier to read.

It's not a huge performance concern, but removing up to 156 malloc calls* for each time we read** or store the style is certainly reason for this.

*Depends on standard library implementations small string optimisation buffer size.
**Happens multiple times as of 4888c9ce.

aaron.ballman accepted this revision.Oct 28 2020, 7:14 AM

Was this caused by a performance concern when profiling something? I'm not opposed to the changes, but I do think the original formulation is easier to read.

It's not a huge performance concern, but removing up to 156 malloc calls* for each time we read** or store the style is certainly reason for this.

*Depends on standard library implementations small string optimisation buffer size.
**Happens multiple times as of 4888c9ce.

Okay, that's sufficiently motivating to me. Thank you, LGTM!

This revision is now accepted and ready to land.Oct 28 2020, 7:14 AM