Skip to content

Instantly share code, notes, and snippets.

Created May 27, 2012 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2815471 to your computer and use it in GitHub Desktop.
Save anonymous/2815471 to your computer and use it in GitHub Desktop.
micro optimization saving a syscall
diff --git c/lib/Mojo/Reactor/Poll.pm i/lib/Mojo/Reactor/Poll.pm
index dd7fab5..5d95478 100644
--- c/lib/Mojo/Reactor/Poll.pm
+++ i/lib/Mojo/Reactor/Poll.pm
@@ -53,10 +53,10 @@ sub one_tick {
# Timers
while (my ($id, $t) = each %{$self->{timers} || {}}) {
- next unless $t->{time} <= time;
+ next unless $t->{time} <= (my $time = time);
# Recurring timer
- if (exists $t->{recurring}) { $t->{time} = time + $t->{recurring} }
+ if (exists $t->{recurring}) { $t->{time} = $time + $t->{recurring} }
# Normal timer
else { $self->remove($id) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment