From 6d6cf8ff004c1ccd3600ed4207495b74612a7525 Mon Sep 17 00:00:00 2001
From: Gabor Greif
SmallPtrSet has all the advantages of SmallSet (and a SmallSet of pointers is -transparently implemented with a SmallPtrSet), but also supports iterators. If +
SmallPtrSet has all the advantages of SmallSet (and a SmallSet of pointers is +transparently implemented with a SmallPtrSet), but also supports iterators. If more than 'N' insertions are performed, a single quadratically probed hash table is allocated and grows as needed, providing extremely efficient access (constant time insertion/deleting/queries with low constant factors) and is very stingy with malloc traffic.
-Note that, unlike std::set, the iterators of SmallPtrSet are invalidated +
Note that, unlike std::set, the iterators of SmallPtrSet are invalidated whenever an insertion occurs. Also, the values visited by the iterators are not visited in sorted order.
@@ -1960,6 +1960,10 @@ for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i errs() << *Inst << "\n"; } +Note that dereferencing a Value::use_iterator*i above several times, consider +doing it only once in the loop body and reusing its result. +Alternatively, it's common to have an instance of the
-
-
+ Declaring objects as const is an important tool of enforcing
+mutation free algorithms (such as analyses etc.). For this purpose above
+iterators come in constant flavors as Value::const_use_iterator
+and Value::const_op_iterator. They automatically arise when
+calling use/op_begin() on const Value*s or
+const User*s respectively. Upon dereferencing, they return
+const Use*s. Otherwise the above patterns remain unchanged.