Skip to content

Change the ignore command to use drain() instead of collecting a value - #12120

Merged
ysthakur merged 2 commits into
nushell:mainfrom
devyn:ignore-drain
Mar 8, 2024
Merged

ysthakur merged 2 commits into
nushell:mainfrom
devyn:ignore-drain

Conversation

@devyn

@devyn devyn commented Mar 8, 2024

Copy link
Copy Markdown
Contributor

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

@ysthakur

ysthakur commented Mar 8, 2024

Copy link
Copy Markdown
Member

Thanks for the PR! Like you said, this'll definitely be helpful if someone's generating a lot of output. It might be worth it to add a test to make sure that when something's piped into ignore, everything's still evaluated, it's just that the output is ignored (a quick search for | ignore doesn't show any such tests). Maybe a pipeline that generates files?

@devyn

devyn commented Mar 8, 2024

Copy link
Copy Markdown
Contributor Author

@ysthakur great idea! I just used print since that would prove that the closure has been evaluated.

@ysthakur

ysthakur commented Mar 8, 2024

Copy link
Copy Markdown
Member

D'oh, I was thinking about echo and cococo, forgot print existed. Everything looks good to me, so I'll go ahead and merge.

@ysthakur
ysthakur merged commit 65af572 into nushell:main Mar 8, 2024
@ysthakur ysthakur added this to the v0.92.0 milestone Mar 8, 2024
@devyn
devyn deleted the ignore-drain branch March 8, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants