Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure nils are removed from sequences #1347

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SteveNewson
Copy link

When a sequence is used, nils trigger a go routine in tea.go here:

case sequenceMsg:
  go func() {
    // Execute commands one at a time, in order.
    for _, cmd := range msg {
      if cmd == nil {
        continue
      }
      //...
    }
  }()

Even though the go routine is short-lived, this can cause a significant performance hit to the runtime. The Batch mechanism eliminates nils before they are processed. This change replicates that behaviour in sequenceMsg.

When a sequence is used, nils trigger a go routine in `tea.go` here:
```
case sequenceMsg:
  go func() {
    // Execute commands one at a time, in order.
    for _, cmd := range msg {
      if cmd == nil {
        continue
      }
      //...
    }
  }()
```
Even though the go routine is short-lived, this can cause a significant
performance hit to the runtime. The Batch mechanism eliminates nils
before they are processed. This change replicates that behaviour in
`sequenceMsg`.
@SteveNewson
Copy link
Author

This issue hit me harder because I was using a sequence in an Update() method where a batch would have been more appropriate. Since the majority of updates resulted in no new commands, I was generating a lot of sequences with nils in them. This resulted in an extremely laggy UI.

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.

1 participant