This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Avoid copying of chunk vectors. NFC.
ClosedPublic

Authored by mstorsjo on Sep 13 2018, 12:50 PM.

Details

Summary

When declaring the pair variable as "auto Pair : Map", it is effectively declared as

std::pair<std::pair<StringRef, uint32_t>, std::vector<Chunk *>>.

This effectively does a full, shallow copy of the Chunk vector, just to be thrown away after each iteration.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Sep 13 2018, 12:50 PM
rnk accepted this revision.Sep 13 2018, 1:01 PM

lgtm

This revision is now accepted and ready to land.Sep 13 2018, 1:01 PM
smeenai added inline comments.
COFF/Writer.cpp
472 ↗(On Diff #165356)

Could this be const?

ruiu added inline comments.Sep 13 2018, 3:41 PM
COFF/Writer.cpp
472 ↗(On Diff #165356)

In lld we don't normally sprinkle const if it is obviously not mutated. I prefer keeping variable scope as narrow as possible rather than adding const in general.

This revision was automatically updated to reflect the committed changes.