From 29ccc08a535a2b3de38c35a9a87b4c9fd9e2952e Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Fri, 24 Dec 2021 18:39:32 -0800 Subject: [PATCH] unusued find_entry member: use it Assuming this was meant to be used when created, simplify two other spots to make use of find_entry(). --- src/env.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/env.cpp b/src/env.cpp index afc3e4766..ce586e3d2 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -765,23 +765,15 @@ maybe_t env_scoped_impl_t::try_get_computed(const wcstring &key) cons } maybe_t env_scoped_impl_t::try_get_local(const wcstring &key) const { - auto cursor = locals_; - while (cursor) { - auto where = cursor->env.find(key); - if (where != cursor->env.end()) { - return where->second; - } - cursor = cursor->next; + maybe_t entry; + for (auto cur = locals_; cur; cur=cur->next) { + if ((entry = cur->find_entry(key))) break; } - return none(); + return entry; // this is either the entry or none() from find_entry } maybe_t env_scoped_impl_t::try_get_global(const wcstring &key) const { - auto where = globals_->env.find(key); - if (where != globals_->env.end()) { - return where->second; - } - return none(); + return globals_->find_entry(key); } maybe_t env_scoped_impl_t::try_get_universal(const wcstring &key) const {