aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-06-14 11:35:44 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-06-14 11:40:25 -0700
commit7c2cf8362201adfd40ced8b5e5b731591ac4a232 (patch)
tree8df502bcbfd5d8de573669f576e9828a7b04a851
parentfca2658a1f1dd6f643b2abbace66b1ff26182414 (diff)
Don't do two map lookups when one will do; NFC
PiperOrigin-RevId: 159001841
-rw-r--r--tensorflow/compiler/xla/service/dfs_hlo_visitor.cc16
1 files changed, 6 insertions, 10 deletions
diff --git a/tensorflow/compiler/xla/service/dfs_hlo_visitor.cc b/tensorflow/compiler/xla/service/dfs_hlo_visitor.cc
index 5b29686100..b9a496be43 100644
--- a/tensorflow/compiler/xla/service/dfs_hlo_visitor.cc
+++ b/tensorflow/compiler/xla/service/dfs_hlo_visitor.cc
@@ -51,22 +51,18 @@ void DfsHloVisitor::SetVisited(const HloInstruction& instruction) {
}
bool DfsHloVisitor::IsVisiting(const HloInstruction& instruction) {
- if (visit_state_.count(&instruction) == 0) {
- return false;
- }
- return visit_state_[&instruction] == VisitState::kVisiting;
+ auto it = visit_state_.find(&instruction);
+ return it != visit_state_.end() && it->second == VisitState::kVisiting;
}
bool DfsHloVisitor::DidVisit(const HloInstruction& instruction) {
- if (visit_state_.count(&instruction) == 0) {
- return false;
- }
- return visit_state_[&instruction] == VisitState::kVisited;
+ auto it = visit_state_.find(&instruction);
+ return it != visit_state_.end() && it->second == VisitState::kVisited;
}
bool DfsHloVisitor::NotVisited(const HloInstruction& instruction) {
- return visit_state_.count(&instruction) == 0 ||
- visit_state_[&instruction] == VisitState::kNotVisited;
+ auto it = visit_state_.find(&instruction);
+ return it == visit_state_.end() || it->second == VisitState::kNotVisited;
}
Status DfsHloVisitor::Preprocess(HloInstruction* hlo) { return Status::OK(); }