Skip to content

Commit

Permalink
Remove Arc from environment::globals()
Browse files Browse the repository at this point in the history
We don't forward this variable for storage in any structs, so there's no reason
to go through an Arc instead of returning the `&'static EnvStack` directly.
  • Loading branch information
mqudsi committed May 17, 2024
1 parent 4ce13f0 commit c6d3bde
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bin/fish_indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ fn throwing_main() -> i32 {
}
}
OutputType::Ansi => {
colored_output = colorize(&output_wtext, &colors, &**EnvStack::globals());
colored_output = colorize(&output_wtext, &colors, EnvStack::globals());
}
OutputType::Html => {
colored_output = html_colorize(&output_wtext, &colors);
Expand Down
2 changes: 1 addition & 1 deletion src/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2473,7 +2473,7 @@ pub fn complete_load(cmd: &wstr, parser: &Parser) -> bool {
let path_to_load = completion_autoloader
.lock()
.expect("mutex poisoned")
.resolve_command(cmd, &**EnvStack::globals());
.resolve_command(cmd, EnvStack::globals());
if let Some(path_to_load) = path_to_load {
Autoload::perform_autoload(&path_to_load, parser);
completion_autoloader
Expand Down
6 changes: 3 additions & 3 deletions src/env/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ impl EnvStack {

/// A variable stack that only represents globals.
/// Do not push or pop from this.
pub fn globals() -> &'static Arc<EnvStack> {
pub fn globals() -> &'static EnvStack {
use std::sync::OnceLock;
static GLOBALS: OnceLock<Arc<EnvStack>> = OnceLock::new();
&GLOBALS.get_or_init(|| Arc::new(EnvStack::new()))
static GLOBALS: OnceLock<EnvStack> = OnceLock::new();
GLOBALS.get_or_init(|| EnvStack::new())
}

/// Access the principal variable stack, associated with the principal parser.
Expand Down
2 changes: 1 addition & 1 deletion src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub fn load(name: &wstr, parser: &Parser) -> bool {
if funcset.allow_autoload(name) {
if let Some(path) = funcset
.autoloader
.resolve_command(name, &**EnvStack::globals())
.resolve_command(name, EnvStack::globals())
{
path_to_autoload = Some(path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/operation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a> OperationContext<'a> {
// Return an operation context that contains only global variables, no parser, and never
// cancels.
pub fn globals() -> OperationContext<'static> {
OperationContext::background(&**EnvStack::globals(), EXPANSION_LIMIT_DEFAULT)
OperationContext::background(EnvStack::globals(), EXPANSION_LIMIT_DEFAULT)
}

/// Construct from a full set of properties.
Expand Down

0 comments on commit c6d3bde

Please sign in to comment.