mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:35:42 +02:00
Change the ignore command to use drain() instead of collecting a value (#12120)
# Description Change the `ignore` command to use `drain()` instead of collecting a value. This saves memory usage when piping a lot of output to `ignore`. There's no reason to keep the output in memory if it's going to be discarded anyway. # User-Facing Changes Probably none # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib`
This commit is contained in:
@ -32,20 +32,20 @@ impl Command for Ignore {
|
||||
&self,
|
||||
_engine_state: &EngineState,
|
||||
_stack: &mut Stack,
|
||||
call: &Call,
|
||||
_call: &Call,
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
input.into_value(call.head);
|
||||
input.drain()?;
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
|
||||
fn run_const(
|
||||
&self,
|
||||
_working_set: &StateWorkingSet,
|
||||
call: &Call,
|
||||
_call: &Call,
|
||||
input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
input.into_value(call.head);
|
||||
input.drain()?;
|
||||
Ok(PipelineData::empty())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user