couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject [3/3] git commit: Avoid unnecessary call when there's no heartbeat defined
Date Mon, 28 Nov 2011 13:01:44 GMT
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/dc1342d8
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/dc1342d8
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/dc1342d8

Branch: refs/heads/1.2.x
Commit: dc1342d8f50a65b60df80b51206bb2927812ed82
Parents: 6b530aa
Author: Filipe David Borba Manana <fdmanana@apache.org>
Authored: Mon Nov 28 12:26:08 2011 +0000
Committer: Filipe David Borba Manana <fdmanana@apache.org>
Committed: Mon Nov 28 13:01:06 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/dc1342d8/src/couchdb/couch_changes.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl
index a20a15e..b0fdb06 100644
--- a/src/couchdb/couch_changes.erl
+++ b/src/couchdb/couch_changes.erl
@@ -527,12 +527,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),


Mime
View raw message