You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2011/11/28 13:54:26 UTC

[3/3] git commit: Avoid unnecessary call when there's no heartbeat defined

Avoid unnecessary call when there's no heartbeat defined

To avoid unncessary process preemption everytime the filter
function returns false.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e18e32b0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e18e32b0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e18e32b0

Branch: refs/heads/master
Commit: e18e32b0b7302beca407f154adc118793b3658b6
Parents: 7cd04e8
Author: Filipe David Borba Manana <fd...@apache.org>
Authored: Mon Nov 28 12:26:08 2011 +0000
Committer: Filipe David Borba Manana <fd...@apache.org>
Committed: Mon Nov 28 12:26:08 2011 +0000

----------------------------------------------------------------------
 src/couchdb/couch_changes.erl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/e18e32b0/src/couchdb/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl
index 6858d77..f124567 100644
--- a/src/couchdb/couch_changes.erl
+++ b/src/couchdb/couch_changes.erl
@@ -534,12 +534,12 @@ reset_heartbeat() ->
     put(last_changes_heartbeat,now()).
 
 maybe_heartbeat(Timeout, TimeoutFun, Acc) ->
-    Now = now(),
     Before = get(last_changes_heartbeat),
     case Before of
     undefined ->
         {ok, Acc};
     _ ->
+        Now = now(),
         case timer:now_diff(Now, Before) div 1000 >= Timeout of
         true ->
             Acc2 = TimeoutFun(Acc),