<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 Dec 28, 2016, at 2:34 PM, Piotr Padlewski via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2016-12-28 22:09 GMT+01:00 Daniel Berlin <span dir="ltr" class=""><<a href="mailto:dberlin@dberlin.org" target="_blank" class="">dberlin@dberlin.org</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="gmail-">On Wed, Dec 28, 2016 at 12:36 PM, Piotr Padlewski via llvm-commits <span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: prazek<br class="">
Date: Wed Dec 28 14:36:08 2016<br class="">
New Revision: 290685<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=290685&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject?rev=290685&view=rev</a><br class="">
Log:<br class="">
[NewGVN] replace emplace_back with push_back<br class=""></blockquote><div class=""><br class=""></div></span><div class="">I'm somewhat against this change.</div><div class="">It would be nice to have coding guidelines here.</div><span class="gmail-"><div class=""> <br class=""></div></span></div></div></div></blockquote><div class="">True, I gonna start thread about it soon. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><div class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br class="">
emplace_back is not faster if it is equivalent to push_back. In this cases emplaced value had the</blockquote></span></div></div></div></blockquote></div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
same type that the one stored in container. It is ugly and it might be even slower (see<br class="">
Scott Meyers presentation about emplacement).<br class=""></blockquote></span></div></div></div></blockquote></div></div></div></div></blockquote><div><br class=""></div><div><div>From what I understand in the video you’re linking, the issue detailed is specifically with *emplace* and not *emplace_back*. </div><div>It is acknowledge in the video that emplace_back is a potential win under some condition ( <a href="https://youtu.be/smqT9Io_bKo?t=2576" class="">https://youtu.be/smqT9Io_bKo?t=2576</a> ) and I didn’t see any mention where emplace_back could be slower?</div><div><br class=""></div></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><div class=""><br class=""></div></span><div class="">I'm going to disagree about "ugly", i don't think it's ugly or not ugly.</div><div class="">If it's really slower, i'd like to see numbers.<br class=""></div><div class="">Otherwise, i think we should just be consistent if we can.</div><div class=""><br class=""></div></div></div></div>
</blockquote></div><br class=""></div><div class="gmail_extra">Some numbers:</div><div class="gmail_extra"><a href="https://youtu.be/smqT9Io_bKo?t=29m16s" class="">https://youtu.be/smqT9Io_bKo?t=29m16s</a><br class=""></div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">It is for map insert/emplace. It probably doesn't matter much for emplace_back, it only can add extra instantiations, </div><div class="gmail_extra">but I guess we don't want to have diffrent rules for using insert/emplace and push_back/emplace_back</div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><br class=""></div><div class="gmail_extra">There is also some useful info here:</div><div class="gmail_extra"><a href="http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html" class="">http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html</a><br class=""></div></div></div></blockquote><br class=""></div><div>I don’t see anything about emplace*_back* being slower here.</div><div><br class=""></div><div>That said, I tend to restrict my use of emplace_back when I actually pass argument(s) of type different than T (i.e. I’m targeting another constructor than the copy-constructor).</div><div>I’d be fine with codifying something in <a href="http://llvm.org/docs/CodingStandards.html" class="">http://llvm.org/docs/CodingStandards.html</a> about this (push_back vs emplace_back).</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div></body></html>