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

irc: use deque for "stack" of recent messages #2327

Merged
merged 1 commit into from
Aug 10, 2022
Merged

Conversation

dgw
Copy link
Member

@dgw dgw commented Jul 20, 2022

Description

Tin. Reading #2320 made me wonder why we used a list with manual pruning (l = l[-10:] after appending), and I couldn't think of a good reason. Updated tests made me pretty confident I could just swap to a deque with maxlen and get pruning for free.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
    • Caveat: Some type-checking stuff gets flagged by flake8, but those should be sorted out already on the actual master branch (they reference code that wasn't changed in this patch).
  • I have tested the functionality of the things this change touches
    • (thanks to Exirel's updated test suite)

Notes

This is a draft because it's built on top of #2320. I will rebase and mark ready for review when that's squashed down.

@dgw dgw added the Tweak label Jul 20, 2022
@dgw dgw added this to the 8.0.0 milestone Jul 20, 2022
@dgw dgw requested a review from a team July 20, 2022 18:42
@dgw
Copy link
Member Author

dgw commented Jul 20, 2022

Thanks for breaking CI, Coveralls. Thankfully it doesn't actually matter yet, because this is only a draft.

@Exirel
Copy link
Contributor

Exirel commented Jul 20, 2022

Neat.

@dgw
Copy link
Member Author

dgw commented Jul 22, 2022

Coveralls is fixed. Still keeping as draft until the base PR is completed.

@dgw dgw mentioned this pull request Jul 24, 2022
4 tasks
@dgw
Copy link
Member Author

dgw commented Jul 24, 2022

Further discussion on #2320 says we should keep thinking about this, perhaps converting the "stack" to prune messages not just by a dumb count, but by time range and/or maximum size in bytes. This can be considered Replaced if one of us gets the motivation to do the fancy way pre-8.0, but should be merged if we don't.

Doesn't save any code lines, but does make the process of updating what
has been said recently look a bit less voodoo-y. I very much prefer
declaring how long the list of "messages" should be where it's
initialized instead of pruning it later.
@dgw dgw force-pushed the message-stack-deque branch from 98660eb to 16f8ca3 Compare August 8, 2022 21:50
@dgw dgw marked this pull request as ready for review August 8, 2022 21:51
Copy link
Contributor

@SnoopJ SnoopJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice little improvement

Copy link
Contributor

@Exirel Exirel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfection.

@dgw dgw merged commit 44171fa into master Aug 10, 2022
@dgw dgw deleted the message-stack-deque branch August 10, 2022 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants