mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 06:56:09 +08:00
Provide an optimized override of get_pwd_slash()
This commit is contained in:
parent
38a7c77e4b
commit
aa950e5c13
@ -1306,6 +1306,14 @@ std::shared_ptr<environment_t> env_stack_t::snapshot() const { return acquire_im
|
||||
|
||||
void env_stack_t::set_argv(wcstring_list_t argv) { set(L"argv", ENV_LOCAL, std::move(argv)); }
|
||||
|
||||
wcstring env_stack_t::get_pwd_slash() const {
|
||||
wcstring pwd = acquire_impl()->perproc_data().pwd;
|
||||
if (!string_suffixes_string(L"/", pwd)) {
|
||||
pwd.push_back(L'/');
|
||||
}
|
||||
return pwd;
|
||||
}
|
||||
|
||||
void env_stack_t::push(bool new_scope) {
|
||||
auto impl = acquire_impl();
|
||||
if (new_scope) {
|
||||
|
@ -199,7 +199,7 @@ class environment_t {
|
||||
virtual ~environment_t();
|
||||
|
||||
/// Returns the PWD with a terminating slash.
|
||||
wcstring get_pwd_slash() const;
|
||||
virtual wcstring get_pwd_slash() const;
|
||||
};
|
||||
|
||||
/// The null environment contains nothing.
|
||||
@ -296,6 +296,9 @@ class env_stack_t final : public environment_t {
|
||||
/// Sets up argv as the given list of strings.
|
||||
void set_argv(wcstring_list_t argv);
|
||||
|
||||
/// Slightly optimized implementation.
|
||||
wcstring get_pwd_slash() const override;
|
||||
|
||||
// Compatibility hack; access the "environment stack" from back when there was just one.
|
||||
static const std::shared_ptr<env_stack_t> &principal_ref();
|
||||
static env_stack_t &principal() { return *principal_ref(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user