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

Don't parse timestamp from message unless we're going to check it #15

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

Conversation

mattrobenolt
Copy link

No description provided.

@kr
Copy link
Contributor

kr commented Aug 30, 2018

Can you give a little background on the motivation for this change? I'd love to understand better why it would be needed. Thanks!

@mattrobenolt
Copy link
Author

No real reason other than it's unnecessary to do so if we're short circuiting with no TTL. The short circuit logic was introduced in #13. And with that, if we're opting to not check TTL, we can make this more efficient.

It's also combining the slight change from #14, to match the docstrings. A TTL of 0 doesn't really make sense.

@mattrobenolt
Copy link
Author

The >= thing also bit me in a project since I set our TTL to 0 since that's what the docs suggest, and couldn't figure out why all messages were being dropped which lead to me digging into the source.

@kr
Copy link
Contributor

kr commented Aug 30, 2018

Ah, I didn't catch the >= change before! I went ahead and committed that separately, since it's definitely a bug where the behavior doesn't match what the docs say.

For this PR, it seems there's no behavior change, and it's purely a refactor/performance improvement. Generally, when performance-motivated changes cause an increase in complexity, I tend to shy away unless there are measurements showing that it'll make a noticeable difference for an application.

@mattrobenolt
Copy link
Author

I mean, I'd hardly say this makes things more complex, and to me, it makes it more clear that the ts bit is only needed if the ttl bit is used. On top of that, it simplifies the if statement.

But this is bikeshedding at this point. :)

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