<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 25, 2015, at 5:32 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Fri, Sep 25, 2015 at 5:28 PM, escha via llvm-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">escha created this revision.<br class="">escha added reviewers: MatzeB, arsenm, resistor.<br class="">escha added a subscriber: llvm-commits.<br class="">escha set the repository for this revision to rL LLVM.<br class=""><br class="">std::vector.resize() is actually about 2-3x slower than using unique_ptr, at least for me; it doesn't compile to bzero because the resize() in std:: consists of repeated appending (agh).</blockquote><div class=""><br class=""></div><div class="">Wait, what? Which standard library has that implementation? (is it necessary/implied by the standard, or just a poorly performing implementation that can/should be fixed?)</div></div></div></blockquote><br class=""></div><div>Unfortunately, like a lot of awful things in std::, it seems to be implied by the standard:</div><div><br class=""></div><div>"<span style="font-family: -apple-system-font; line-height: 16px;" class="">If the current size is less than </span><code style="line-height: 16px;" class="">count</code><span style="font-family: -apple-system-font; line-height: 16px;" class="">,</span></div><div style="font-family: -apple-system-font; line-height: 16px;" class="">1) additional <a href="http://en.cppreference.com/w/cpp/concept/DefaultInsertable" title="cpp/concept/DefaultInsertable" class="">default-inserted</a> elements are appended</div><div style="font-family: -apple-system-font; line-height: 16px;" class="">2) additional copies of <code class="">value</code> are appended”</div><div style="font-family: -apple-system-font; line-height: 16px;" class=""><br class=""></div><div style="font-family: -apple-system-font; line-height: 16px;" class="">The other option here is probably to use .reserve() and then .data(), and then bzero that (which gives the same results performance-wise), but that seems vastly uglier than just switching to a lighter-weight data structure.</div><div style="font-family: -apple-system-font; line-height: 16px;" class=""><br class=""></div><div style="font-family: -apple-system-font; line-height: 16px;" class="">—escha</div></body></html>