[PATCH] D43709: [WebAssembly] Remove redundant local variables.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 18:09:01 PST 2018


ruiu created this revision.
ruiu added a reviewer: sbc100.
Herald added subscribers: sunfish, aheejin, jgravelle-google, dschuff, jfb.

[WebAssembly] Remove redundant local variables.


https://reviews.llvm.org/D43709

Files:
  lld/wasm/OutputSections.cpp


Index: lld/wasm/OutputSections.cpp
===================================================================
--- lld/wasm/OutputSections.cpp
+++ lld/wasm/OutputSections.cpp
@@ -107,15 +107,12 @@
   memcpy(Buf, Header.data(), Header.size());
   Buf += Header.size();
 
-  uint8_t *ContentsStart = Buf;
-
   // Write code section headers
   memcpy(Buf, CodeSectionHeader.data(), CodeSectionHeader.size());
-  Buf += CodeSectionHeader.size();
 
   // Write code section bodies
-  parallelForEach(Functions, [ContentsStart](const InputChunk *Chunk) {
-    Chunk->writeTo(ContentsStart);
+  parallelForEach(Functions, [&](const InputChunk *Chunk) {
+    Chunk->writeTo(Buf);
   });
 }
 
@@ -168,19 +165,17 @@
   memcpy(Buf, Header.data(), Header.size());
   Buf += Header.size();
 
-  uint8_t *ContentsStart = Buf;
-
   // Write data section headers
   memcpy(Buf, DataSectionHeader.data(), DataSectionHeader.size());
 
-  parallelForEach(Segments, [ContentsStart](const OutputSegment *Segment) {
+  parallelForEach(Segments, [&](const OutputSegment *Segment) {
     // Write data segment header
-    uint8_t *SegStart = ContentsStart + Segment->getSectionOffset();
+    uint8_t *SegStart = Buf + Segment->getSectionOffset();
     memcpy(SegStart, Segment->Header.data(), Segment->Header.size());
 
     // Write segment data payload
     for (const InputChunk *Chunk : Segment->InputSegments)
-      Chunk->writeTo(ContentsStart);
+      Chunk->writeTo(Buf);
   });
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43709.135756.patch
Type: text/x-patch
Size: 1461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180224/ca2abaa5/attachment.bin>


More information about the llvm-commits mailing list