[llvm-commits] [PATCH] Add DenseMap::lookup

Daniel Dunbar daniel at zuster.org
Thu Aug 28 16:37:31 PDT 2008


The attached patch adds DenseMap::lookup:
+  /// lookup - Return the entry for the specified key, or a default
+  /// value if no such entry exists.

This is useful for situations where you just want to get an entry from
the DenseMap if it exists. Code like:
--
  llvm::Function *Fn = MethodDefinitions[MD];
  if (!Fn)
    return 0;
--
is succinct but is wastefully adding entries into MethodDefinitions.

 - Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080828/d20c56c6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add_DenseMap_lookup.patch
Type: application/octet-stream
Size: 671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080828/d20c56c6/attachment.obj>


More information about the llvm-commits mailing list