[lld] r234927 - [ELF] Write whole std::vector using a single `memcpy` call
Simon Atanasyan
simon at atanasyan.com
Tue Apr 14 11:53:15 PDT 2015
Author: atanasyan
Date: Tue Apr 14 13:53:14 2015
New Revision: 234927
URL: http://llvm.org/viewvc/llvm-project?rev=234927&view=rev
Log:
[ELF] Write whole std::vector using a single `memcpy` call
We do not need to iterate over `_buckets` and `_chains` vectors and
write all elements one by one.
No functional changes.
Modified:
lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=234927&r1=234926&r2=234927&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Tue Apr 14 13:53:14 2015
@@ -1414,17 +1414,10 @@ public:
std::memcpy(dest, bucketChainCounts, sizeof(bucketChainCounts));
dest += sizeof(bucketChainCounts);
// write bucket values
- for (auto bi : _buckets) {
- uint32_t val = (bi);
- std::memcpy(dest, &val, sizeof(uint32_t));
- dest += sizeof(uint32_t);
- }
+ std::memcpy(dest, _buckets.data(), _buckets.size() * sizeof(uint32_t));
+ dest += _buckets.size() * sizeof(uint32_t);
// write chain values
- for (auto ci : _chains) {
- uint32_t val = (ci);
- std::memcpy(dest, &val, sizeof(uint32_t));
- dest += sizeof(uint32_t);
- }
+ std::memcpy(dest, _chains.data(), _chains.size() * sizeof(uint32_t));
}
private:
More information about the llvm-commits
mailing list