Created
May 27, 2012 18:48
-
-
Save anonymous/2815471 to your computer and use it in GitHub Desktop.
micro optimization saving a syscall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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