From: Gabor Greif Date: Fri, 26 Mar 2010 19:30:47 +0000 (+0000) Subject: add a blurb on const versions of chain traversals and a word of caution X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4de7368bf92897d3b943423934e0a95d5a99d2cd;p=oota-llvm.git add a blurb on const versions of chain traversals and a word of caution git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99638 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index cf936d1571a..b6c9a8793c2 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -1211,14 +1211,14 @@ and erasing, but does not support iteration.

-

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.