[PATCH] D18440: Don't use potentially invalidated iterator

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 08:59:24 PDT 2016


On Thu, Mar 31, 2016 at 8:50 AM, Stephan Bergmann via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> sberg added a comment.
>
> Dropped the const.  The type of n is int, so taking by value is fine.
> (But guess it's better to stick to auto, in case the value type of
> FuncletMembership should ever change.)
>

We don't generally use auto for future proofing like this - only if it
improves readability. I would argue that since we didn't have type
information when it was one line, tehre's not much reason to add type
information now that it's two...

(oh, and of course we can't take it by const ref even if it is expensive -
because the whole point is that that ref may be invalidated by the map
access... - but I suppose we could add std::move on the RHS of the
assignment if we were being generically defensive/matching the possible
behavior of the original code, but that'd be weird)


>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D18440
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160331/d45c7505/attachment.html>


More information about the llvm-commits mailing list