[PATCH] D143976: [ADT] Add lookupOrTrap method to DenseMap and StringMap
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 03:55:35 PST 2023
foad added a comment.
With apologies for bikeshedding:
I don't love the "OrTrap" name. It might trap in a Debug build, but it surely won't in a Release build. Anyway I don't think the name needs to say what the consequences might be if the key does not exist.
How about calling it just "lookup", and using a longer name like "lookupOrDefaultConstruct" for the less-obvious behaviour of the current lookup method? (Is there really much code that relies on its "or default construct" behaviour? And anyway aren't there more STL-like ways of getting that behaviour, like using `operator[]`?)
Or why not call it "at <https://en.cppreference.com/w/cpp/container/map/at>"?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143976/new/
https://reviews.llvm.org/D143976
More information about the llvm-commits
mailing list