<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Fair points, all. Although I think 'distance' has a more discoverable name (there's a direct analog in the STL), 'size' seems closer to what the function is really doing.<div class=""><br class=""></div><div class="">Does anyone have other reasons to stick with 'distance'?<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On May 14, 2018, at 11:58 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I feel like a range-based version of std::distance isn't so much distance anymore, by virtue of it being over a range & is actually probably more suitably named 'size'. (in the case of std::distance, the name is really talking about the two elements separately "what's the distance from this iterator to this other iterator" not talking about a range defined by those two iterators - so the name make sense there in a way that I don't think it makes sense for ranges ("what is the distance of a range?" isn't a cromulant question, I think... ))<br class=""><br class="">I'd vote for llvm::size (& I think the general idea/concept/thing is a good thing to add). <br class=""><br class="">Though I guess one issue with size/distance is: how expensive is this? I'd sort of be inclined only to provide this for ranges over random access iterators (so it's only O(1), never O(N)), maybe? Let the more obscure cases use std::distance(begin, end) to hopefully clarify that they're weird/interesting/maybe expensive.</div></div></blockquote><div><br class=""></div><div>This seems reasonable as well.</div><div><br class=""></div><div>vedant</div><br class=""><blockquote type="cite" class=""><div class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, May 10, 2018 at 11:30 AM Craig Topper via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">craig.topper added a comment.<br class="">
<br class="">
I think if its equivalent to range-based version of std::distance its name should be llvm::distance.<br class="">
<br class="">
My comment was just an observation that a majority of the uses were for predecessors/successors and maybe we should just make that easier. We already have pred_empty and succ_empty. pred_size and succ_size don't seem like much of a stretch.<br class="">
<br class="">
<br class="">
<a href="https://reviews.llvm.org/D46668" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D46668</a><br class="">
<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></body></html>