<div dir="ltr">An executable does not contain a bunch of sections but usually only a few, so there's no performance concern on looping over them. For readability I prefer having a separate loop rather than mixing output and counting in one loop.</div>

<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 13, 2013 at 11:30 AM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Cant this be done while you write the output file. You need to write every section anyways and you can avoid these loops.<br>


<br>
Thanks<br>
<br>
Shankar Easwaran<div><div class="h5"><br>
<br>
On 9/13/2013 1:03 PM, Rui Ueyama wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<br>
================<br>
Comment at: lib/ReaderWriter/PECOFF/<u></u>WriterPECOFF.cpp:472<br>
@@ +471,3 @@<br>
+<br>
+  virtual bool isCodeSection() {<br>
+    return _sectionHeader.Characteristics & llvm::COFF::IMAGE_SCN_CNT_<u></u>CODE;<br>
----------------<br>
Why virtual?<br>
<br>
================<br>
Comment at: lib/ReaderWriter/PECOFF/<u></u>WriterPECOFF.cpp:923<br>
@@ +922,3 @@<br>
+<br>
+  uint64_t calcSizeOfInitializedData() {<br>
+    uint64_t ret = 0;<br>
----------------<br>
I'd define a helper function calculateSectionSize(<u></u>SectionCharacteristics) containing the for loop and use it in the following three functions, rather than repeating the same loop three times.<br>
<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D1616" target="_blank">http://llvm-reviews.chandlerc.<u></u>com/D1616</a><br></div></div><div class="im">
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
<br>
<br>
</div></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>