[llvm-commits] [llvm] r74676 - in /llvm/trunk: include/llvm/Analysis/Dominators.h lib/Target/X86/X86FastISel.cpp lib/Transforms/Scalar/JumpThreading.cpp lib/Transforms/Scalar/TailDuplication.cpp tools/llvm-prof/llvm-prof.cpp

Daniel Dunbar daniel at zuster.org
Wed Jul 1 18:28:48 PDT 2009


Hi Dan,

Some of these uses would be simpler if they used lookup() instead of
find (assuming the null value shouldn't be in the map). For example,

On Wed, Jul 1, 2009 at 5:17 PM, Dan Gohman<gohman at apple.com> wrote:
>   DomTreeNodeBase<NodeT> *getNodeForBlock(NodeT *BB) {
> -    if (DomTreeNodeBase<NodeT> *BBNode = this->DomTreeNodes[BB])
> -      return BBNode;
> +    typename DomTreeNodeMapType::iterator I = this->DomTreeNodes.find(BB);
> +    if (I != this->DomTreeNodes.end() && I->second)
> +      return I->second;

This can be written as:
--
    if (DomTreeNodeBase<NodeT> *Node = this->DomTreeNodes.lookup(BB))
      return Node;
--

 - Daniel




More information about the llvm-commits mailing list