This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho][nfc] Avoid using std::map for PlatformKinds
ClosedPublic

Authored by int3 on Jul 11 2021, 1:51 PM.

Details

Reviewers
gkm
thakis
Group Reviewers
Restricted Project
Commits
rGf6e84a84f95e: [lld-macho][nfc] Avoid using std::map for PlatformKinds
Summary

The mappings we were using had a small number of keys, so a vector is
probably better. This allows us to remove the last usage of std::map in
our codebase.

I also used removeSimulator to simplify the code a bit further.

Diff Detail

Event Timeline

int3 created this revision.Jul 11 2021, 1:51 PM
Herald added a project: Restricted Project. · View Herald Transcript
int3 requested review of this revision.Jul 11 2021, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2021, 1:51 PM

switch statements are too verbose? In the removeSimulator case, I would expect it to be shorter and more readable. And why is removeSimulatornot somewhere in llvm Binaryformat?

int3 added a comment.Jul 11 2021, 2:15 PM

In the removeSimulator case, I would expect it to be shorter and more readable.

I prefer to keep to the same code pattern as the other two PlatformKind mappings.

And why is removeSimulator not somewhere in llvm Binaryformat?

That file doesn't seem to have a whole lot of helper functions, just struct definitions.

thakis accepted this revision.Jul 11 2021, 2:44 PM
thakis added a subscriber: thakis.
thakis added inline comments.
lld/MachO/Driver.cpp
854

I agree that a switch seems like the obvious fit here, but *shrug*

This revision is now accepted and ready to land.Jul 11 2021, 2:44 PM
int3 marked an inline comment as done.Jul 11 2021, 3:22 PM
int3 added inline comments.
lld/MachO/Driver.cpp
854

okay yeah I forgot that we don't need an extra line for break since we can return early. changing

This revision was automatically updated to reflect the committed changes.
int3 marked an inline comment as done.