[STLExtras] Add size() for ranges, and remove distance()

r332057 introduced distance() for ranges. Based on post-commit feedback,
this renames distance() to size(). The new size() is also only enabled
when the operation is O(1).

Differential Revision: https://reviews.llvm.org/D46976

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332551 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vedant Kumar
2018-05-16 23:20:42 +00:00
parent 309c9c43a7
commit ca6a4d968e
8 changed files with 23 additions and 14 deletions
+3 -3
View File
@@ -1273,7 +1273,7 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN,
// the removal hasn't changed the structure at all. This is an important
// special case and we can directly exit the entire routine more
// efficiently as soon as we discover it.
if (distance(RefSCCNodes) == NumRefSCCNodes) {
if (llvm::size(RefSCCNodes) == NumRefSCCNodes) {
// Clear out the low link field as we won't need it.
for (Node *N : RefSCCNodes)
N->LowLink = -1;
@@ -1739,7 +1739,7 @@ static void printNode(raw_ostream &OS, LazyCallGraph::Node &N) {
}
static void printSCC(raw_ostream &OS, LazyCallGraph::SCC &C) {
ptrdiff_t Size = distance(C);
ptrdiff_t Size = size(C);
OS << " SCC with " << Size << " functions:\n";
for (LazyCallGraph::Node &N : C)
@@ -1747,7 +1747,7 @@ static void printSCC(raw_ostream &OS, LazyCallGraph::SCC &C) {
}
static void printRefSCC(raw_ostream &OS, LazyCallGraph::RefSCC &C) {
ptrdiff_t Size = distance(C);
ptrdiff_t Size = size(C);
OS << " RefSCC with " << Size << " call SCCs:\n";
for (LazyCallGraph::SCC &InnerC : C)