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

Update previous hash during event tick + general refactoring #311

Merged
merged 3 commits into from
Feb 19, 2014

Conversation

rzezeski
Copy link
Contributor

Currently yz_events:sync_indexes is called on every tick because the previous hash is not being updated. I noticed this when investigating #304.

  • Sync indexes IFF full check or hash has changed.
  • Fix off-by-one error in full check.
  • Add MAYBE macro for tighter code.

This can be verified by using redbug to verify sync_indexes is called every 60 seconds.

> redbug:start("yz_events:sync_indexes -> return", [{time, 180000}]).

Update the previous hash during `yz_events` tick. Otherwise
`sync_indexes` will be called on every tick which could be expensive.
Start NumTicks at 1 so that it actually does full check at N seconds
rather than N+1.
Add MAYBE macro that conditionally evaluates expression based on another
expression. It can be used to reduce lines of code where you would
usually use a case expression to match against a boolean.

Use the MAYBE macro in event tick to clean up code a bit.
end).

-define(MAYBE(Check, Expression),
?MAYBE(Check, Expression, ok)).
Copy link
Contributor

Choose a reason for hiding this comment

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

Welcome to CPP ;)

@coderoshi
Copy link
Contributor

+1, if you're into this kind of macro thing. Tested and works.

rzezeski added a commit that referenced this pull request Feb 19, 2014
Update previous hash during event tick + general refactoring
@rzezeski rzezeski merged commit f4b4595 into develop Feb 19, 2014
@rzezeski rzezeski added this to the 0.14.0 milestone Feb 19, 2014
@rzezeski
Copy link
Contributor Author

Gah, I mean to link this is issue #306, not 304.

@rzezeski rzezeski deleted the bugfix/rz/full-check branch February 19, 2014 06:44
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