mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-21 15:01:16 -03:00
Eliminate env_snapshot_t::current()
These uses are better served by passing in the real environment stack, now that we have environment_t as a shared base class.
This commit is contained in:
12
src/env.cpp
12
src/env.cpp
@@ -1658,19 +1658,7 @@ env_vars_snapshot_t::env_vars_snapshot_t(const environment_t &source, const wcha
|
||||
|
||||
env_vars_snapshot_t::~env_vars_snapshot_t() = default;
|
||||
|
||||
// The "current" variables are not a snapshot at all, but instead trampoline to env_get, etc.
|
||||
// We identify the current snapshot based on pointer values.
|
||||
// This is an ugly thing that has to go away.
|
||||
const env_vars_snapshot_t env_vars_snapshot_t::s_current;
|
||||
const env_vars_snapshot_t &env_vars_snapshot_t::current() { return s_current; }
|
||||
|
||||
bool env_vars_snapshot_t::is_current() const { return this == &s_current; }
|
||||
|
||||
maybe_t<env_var_t> env_vars_snapshot_t::get(const wcstring &key, env_mode_flags_t mode) const {
|
||||
// If we represent the current state, bounce to env_get.
|
||||
if (this->is_current()) {
|
||||
return env_get(key, mode);
|
||||
}
|
||||
auto iter = vars.find(key);
|
||||
if (iter == vars.end()) return none();
|
||||
return iter->second;
|
||||
|
||||
Reference in New Issue
Block a user