aboutsummaryrefslogtreecommitdiff
path: root/source/val
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2017-06-27 14:21:33 -0700
committerDavid Neto <dneto@google.com>2017-06-28 11:13:26 -0400
commitd431b69c28f1d608a14e85b93c60e99e85984c16 (patch)
tree26ad8ddfe9187534cbdf64fe939b82496d11574e /source/val
parentc14966b882070f4078e26fb0beae11dacabf4810 (diff)
downloadspirv-tools-d431b69c28f1d608a14e85b93c60e99e85984c16.tar.gz
Don't do hash lookup twice in FindDef
Diffstat (limited to 'source/val')
-rw-r--r--source/val/validation_state.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp
index 350b09df..850f15ee 100644
--- a/source/val/validation_state.cpp
+++ b/source/val/validation_state.cpp
@@ -209,25 +209,17 @@ bool ValidationState_t::IsDefinedId(uint32_t id) const {
}
const Instruction* ValidationState_t::FindDef(uint32_t id) const {
- if (all_definitions_.count(id) == 0) {
+ auto it = all_definitions_.find(id);
+ if (it == all_definitions_.end())
return nullptr;
- } else {
- /// We are in a const function, so we cannot use defs.operator[]().
- /// Luckily we know the key exists, so defs_.at() won't throw an
- /// exception.
- return all_definitions_.at(id);
- }
+ return it->second;
}
Instruction* ValidationState_t::FindDef(uint32_t id) {
- if (all_definitions_.count(id) == 0) {
+ auto it = all_definitions_.find(id);
+ if (it == all_definitions_.end())
return nullptr;
- } else {
- /// We are in a const function, so we cannot use defs.operator[]().
- /// Luckily we know the key exists, so defs_.at() won't throw an
- /// exception.
- return all_definitions_.at(id);
- }
+ return it->second;
}
// Increments the instruction count. Used for diagnostic