formatting
This commit is contained in:
parent
8f4f705a7c
commit
a0ed00fcba
|
@ -89,11 +89,7 @@ pub fn evaluate_repl(
|
|||
if let Err(e) = convert_env_values(engine_state, &unique_stack) {
|
||||
report_error_new(engine_state, &e);
|
||||
}
|
||||
perf!(
|
||||
"translate env vars",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("translate env vars", start_time, use_color);
|
||||
|
||||
// seed env vars
|
||||
unique_stack.add_env_var(
|
||||
|
@ -222,22 +218,14 @@ fn get_line_editor(
|
|||
|
||||
// Now that reedline is created, get the history session id and store it in engine_state
|
||||
store_history_id_in_engine(engine_state, &line_editor);
|
||||
perf!(
|
||||
"setup reedline",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("setup reedline", start_time, use_color);
|
||||
|
||||
if let Some(history) = engine_state.history_config() {
|
||||
start_time = std::time::Instant::now();
|
||||
|
||||
line_editor = setup_history(nushell_path, engine_state, line_editor, history)?;
|
||||
|
||||
perf!(
|
||||
"setup history",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("setup history", start_time, use_color);
|
||||
}
|
||||
Ok(line_editor)
|
||||
}
|
||||
|
@ -280,22 +268,14 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
if let Err(err) = engine_state.merge_env(&mut stack, cwd) {
|
||||
report_error_new(engine_state, &err);
|
||||
}
|
||||
perf!(
|
||||
"merge env",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("merge env", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
// Reset the ctrl-c handler
|
||||
if let Some(ctrlc) = &mut engine_state.ctrlc {
|
||||
ctrlc.store(false, Ordering::SeqCst);
|
||||
}
|
||||
perf!(
|
||||
"reset ctrlc",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("reset ctrlc", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
// Right before we start our prompt and take input from the user,
|
||||
|
@ -305,11 +285,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
report_error_new(engine_state, &err);
|
||||
}
|
||||
}
|
||||
perf!(
|
||||
"pre-prompt hook",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("pre-prompt hook", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
// Next, check all the environment variables they ask for
|
||||
|
@ -318,11 +294,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
if let Err(error) = hook::eval_env_change_hook(env_change, engine_state, &mut stack) {
|
||||
report_error_new(engine_state, &error)
|
||||
}
|
||||
perf!(
|
||||
"env-change hook",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("env-change hook", start_time, use_color);
|
||||
|
||||
let engine_reference = Arc::new(engine_state.clone());
|
||||
let config = engine_state.get_config();
|
||||
|
@ -334,11 +306,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
vi_normal: map_nucursorshape_to_cursorshape(config.cursor_shape_vi_normal),
|
||||
emacs: map_nucursorshape_to_cursorshape(config.cursor_shape_emacs),
|
||||
};
|
||||
perf!(
|
||||
"get config/cursor config",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("get config/cursor config", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
// at this line we have cloned the state for the completer and the transient prompt
|
||||
|
@ -370,11 +338,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
.with_ansi_colors(config.use_ansi_coloring)
|
||||
.with_cursor_config(cursor_config);
|
||||
|
||||
perf!(
|
||||
"reedline builder",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("reedline builder", start_time, use_color);
|
||||
|
||||
let style_computer = StyleComputer::from_config(engine_state, &stack_arc);
|
||||
|
||||
|
@ -389,11 +353,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
line_editor.disable_hints()
|
||||
};
|
||||
|
||||
perf!(
|
||||
"reedline coloring/style_computer",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("reedline coloring/style_computer", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
trace!("adding menus");
|
||||
|
@ -403,11 +363,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
Reedline::create()
|
||||
});
|
||||
|
||||
perf!(
|
||||
"reedline adding menus",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("reedline adding menus", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
let buffer_editor = get_editor(engine_state, &stack_arc, Span::unknown());
|
||||
|
@ -424,11 +380,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
line_editor
|
||||
};
|
||||
|
||||
perf!(
|
||||
"reedline buffer_editor",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("reedline buffer_editor", start_time, use_color);
|
||||
|
||||
if let Some(history) = engine_state.history_config() {
|
||||
start_time = std::time::Instant::now();
|
||||
|
@ -438,22 +390,14 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
}
|
||||
}
|
||||
|
||||
perf!(
|
||||
"sync_history",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("sync_history", start_time, use_color);
|
||||
}
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
// Changing the line editor based on the found keybindings
|
||||
line_editor = setup_keybindings(engine_state, line_editor);
|
||||
|
||||
perf!(
|
||||
"keybindings",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("keybindings", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
let config = &engine_state.get_config().clone();
|
||||
|
@ -470,11 +414,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
nu_prompt,
|
||||
);
|
||||
|
||||
perf!(
|
||||
"update_prompt",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("update_prompt", start_time, use_color);
|
||||
|
||||
*entry_num += 1;
|
||||
|
||||
|
@ -501,11 +441,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
// so we should avoid it or making stack cheaper to clone.
|
||||
let mut stack = Arc::unwrap_or_clone(stack_arc);
|
||||
|
||||
perf!(
|
||||
"line_editor setup",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("line_editor setup", start_time, use_color);
|
||||
|
||||
let line_editor_input_time = std::time::Instant::now();
|
||||
match input {
|
||||
|
@ -542,11 +478,7 @@ fn loop_iteration(ctx: LoopContext) -> (bool, Stack, Reedline) {
|
|||
}
|
||||
}
|
||||
|
||||
perf!(
|
||||
"pre_execution_hook",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("pre_execution_hook", start_time, use_color);
|
||||
|
||||
let mut repl = engine_state.repl_state.lock().expect("repl state mutex");
|
||||
repl.cursor_pos = line_editor.current_insertion_point();
|
||||
|
@ -995,11 +927,7 @@ fn run_shell_integration_osc2(
|
|||
// ESC]2;stringBEL -- Set window title to string
|
||||
run_ansi_sequence(&format!("\x1b]2;{title}\x07"));
|
||||
|
||||
perf!(
|
||||
"set title with command osc2",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("set title with command osc2", start_time, use_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
60
src/main.rs
60
src/main.rs
|
@ -219,11 +219,7 @@ fn main() -> Result<()> {
|
|||
|
||||
logger(|builder| configure(&level, &target, filters, builder))?;
|
||||
// info!("start logging {}:{}:{}", file!(), line!(), column!());
|
||||
perf!(
|
||||
"start logging",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("start logging", start_time, use_color);
|
||||
}
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
|
@ -242,21 +238,13 @@ fn main() -> Result<()> {
|
|||
"env-path",
|
||||
parsed_nu_cli_args.env_file.as_ref(),
|
||||
);
|
||||
perf!(
|
||||
"set_config_path",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("set_config_path", start_time, use_color);
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
start_time = std::time::Instant::now();
|
||||
terminal::acquire(engine_state.is_interactive);
|
||||
perf!(
|
||||
"acquire_terminal",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("acquire_terminal", start_time, use_color);
|
||||
}
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
|
@ -270,20 +258,12 @@ fn main() -> Result<()> {
|
|||
|
||||
engine_state.add_env_var("NU_LIB_DIRS".into(), Value::list(vals, span));
|
||||
}
|
||||
perf!(
|
||||
"NU_LIB_DIRS setup",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("NU_LIB_DIRS setup", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
// First, set up env vars as strings only
|
||||
gather_parent_env_vars(&mut engine_state, &init_cwd);
|
||||
perf!(
|
||||
"gather env vars",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("gather env vars", start_time, use_color);
|
||||
|
||||
engine_state.add_env_var(
|
||||
"NU_VERSION".to_string(),
|
||||
|
@ -344,11 +324,7 @@ fn main() -> Result<()> {
|
|||
}
|
||||
std::process::exit(0)
|
||||
}
|
||||
perf!(
|
||||
"run test_bins",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("run test_bins", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
let input = if let Some(redirect_stdin) = &parsed_nu_cli_args.redirect_stdin {
|
||||
|
@ -358,20 +334,12 @@ fn main() -> Result<()> {
|
|||
trace!("not redirecting stdin");
|
||||
PipelineData::empty()
|
||||
};
|
||||
perf!(
|
||||
"redirect stdin",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("redirect stdin", start_time, use_color);
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
// Set up the $nu constant before evaluating config files (need to have $nu available in them)
|
||||
engine_state.generate_nu_constant();
|
||||
perf!(
|
||||
"create_nu_constant",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("create_nu_constant", start_time, use_color);
|
||||
|
||||
#[cfg(feature = "plugin")]
|
||||
if let Some(plugins) = &parsed_nu_cli_args.plugins {
|
||||
|
@ -409,20 +377,12 @@ fn main() -> Result<()> {
|
|||
}
|
||||
engine_state.merge_delta(working_set.render())?;
|
||||
|
||||
perf!(
|
||||
"load plugins specified in --plugins",
|
||||
start_time,
|
||||
use_color
|
||||
)
|
||||
perf!("load plugins specified in --plugins", start_time, use_color)
|
||||
}
|
||||
|
||||
start_time = std::time::Instant::now();
|
||||
if parsed_nu_cli_args.lsp {
|
||||
perf!(
|
||||
"lsp starting",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("lsp starting", start_time, use_color);
|
||||
|
||||
if parsed_nu_cli_args.no_config_file.is_none() {
|
||||
let mut stack = nu_protocol::engine::Stack::new();
|
||||
|
|
72
src/run.rs
72
src/run.rs
|
@ -35,11 +35,7 @@ pub(crate) fn run_commands(
|
|||
#[cfg(feature = "plugin")]
|
||||
read_plugin_file(engine_state, parsed_nu_cli_args.plugin_file, NUSHELL_FOLDER);
|
||||
|
||||
perf!(
|
||||
"read plugins",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("read plugins", start_time, use_color);
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
// If we have a env file parameter *OR* we have a login shell parameter, read the env file
|
||||
|
@ -54,11 +50,7 @@ pub(crate) fn run_commands(
|
|||
config_files::read_default_env_file(engine_state, &mut stack)
|
||||
}
|
||||
|
||||
perf!(
|
||||
"read env.nu",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("read env.nu", start_time, use_color);
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
// If we have a config file parameter *OR* we have a login shell parameter, read the config file
|
||||
|
@ -71,11 +63,7 @@ pub(crate) fn run_commands(
|
|||
);
|
||||
}
|
||||
|
||||
perf!(
|
||||
"read config.nu",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("read config.nu", start_time, use_color);
|
||||
|
||||
// If we have a login shell parameter, read the login file
|
||||
let start_time = std::time::Instant::now();
|
||||
|
@ -83,11 +71,7 @@ pub(crate) fn run_commands(
|
|||
config_files::read_loginshell_file(engine_state, &mut stack);
|
||||
}
|
||||
|
||||
perf!(
|
||||
"read login.nu",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("read login.nu", start_time, use_color);
|
||||
}
|
||||
|
||||
// Before running commands, set up the startup time
|
||||
|
@ -111,11 +95,7 @@ pub(crate) fn run_commands(
|
|||
report_error_new(engine_state, &err);
|
||||
std::process::exit(1);
|
||||
}
|
||||
perf!(
|
||||
"evaluate_commands",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("evaluate_commands", start_time, use_color);
|
||||
}
|
||||
|
||||
pub(crate) fn run_file(
|
||||
|
@ -138,11 +118,7 @@ pub(crate) fn run_file(
|
|||
let start_time = std::time::Instant::now();
|
||||
#[cfg(feature = "plugin")]
|
||||
read_plugin_file(engine_state, parsed_nu_cli_args.plugin_file, NUSHELL_FOLDER);
|
||||
perf!(
|
||||
"read plugins",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("read plugins", start_time, use_color);
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
// only want to load config and env if relative argument is provided.
|
||||
|
@ -156,11 +132,7 @@ pub(crate) fn run_file(
|
|||
} else {
|
||||
config_files::read_default_env_file(engine_state, &mut stack)
|
||||
}
|
||||
perf!(
|
||||
"read env.nu",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("read env.nu", start_time, use_color);
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
if parsed_nu_cli_args.config_file.is_some() {
|
||||
|
@ -171,11 +143,7 @@ pub(crate) fn run_file(
|
|||
false,
|
||||
);
|
||||
}
|
||||
perf!(
|
||||
"read config.nu",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("read config.nu", start_time, use_color);
|
||||
}
|
||||
|
||||
// Regenerate the $nu constant to contain the startup time and any other potential updates
|
||||
|
@ -192,11 +160,7 @@ pub(crate) fn run_file(
|
|||
report_error_new(engine_state, &err);
|
||||
std::process::exit(1);
|
||||
}
|
||||
perf!(
|
||||
"evaluate_file",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("evaluate_file", start_time, use_color);
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
let last_exit_code = stack.get_env_var(&*engine_state, "LAST_EXIT_CODE");
|
||||
|
@ -208,11 +172,7 @@ pub(crate) fn run_file(
|
|||
}
|
||||
}
|
||||
}
|
||||
perf!(
|
||||
"get exit code",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("get exit code", start_time, use_color);
|
||||
}
|
||||
|
||||
pub(crate) fn run_repl(
|
||||
|
@ -238,11 +198,7 @@ pub(crate) fn run_repl(
|
|||
|
||||
// Reload use_color from config in case it's different from the default value
|
||||
let use_color = engine_state.get_config().use_ansi_coloring;
|
||||
perf!(
|
||||
"setup_config",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("setup_config", start_time, use_color);
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
let ret_val = evaluate_repl(
|
||||
|
@ -253,11 +209,7 @@ pub(crate) fn run_repl(
|
|||
parsed_nu_cli_args.no_std_lib,
|
||||
entire_start_time,
|
||||
);
|
||||
perf!(
|
||||
"evaluate_repl",
|
||||
start_time,
|
||||
use_color
|
||||
);
|
||||
perf!("evaluate_repl", start_time, use_color);
|
||||
|
||||
ret_val
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user