couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [3/5] couch-replicator commit: updated refs/heads/pu to 4965655
Date Thu, 01 May 2014 11:40:46 GMT
Avoid anoynmous function for is_replicator_db test

Before when we used a regexp to perform this check we used an anonymous
function so that we could cache the compiled regexp in its closure.
Since we stopped using a regexp this is no longer necessary.

BugzId: 24266

Conflicts:
	src/couch_replicator_manager.erl


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

Branch: refs/heads/pu
Commit: 5e2c85556c6c2ae08e29290192490149bd95f127
Parents: abd3d9d
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Thu Oct 17 18:44:16 2013 -0500
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Apr 29 16:30:23 2014 +0100

----------------------------------------------------------------------
 src/couch_replicator_manager.erl | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/5e2c8555/src/couch_replicator_manager.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_manager.erl b/src/couch_replicator_manager.erl
index 99cf786..d1c4abe 100644
--- a/src/couch_replicator_manager.erl
+++ b/src/couch_replicator_manager.erl
@@ -340,12 +340,11 @@ has_valid_rep_id(_Else) ->
 
 db_update_notifier() ->
     Server = self(),
-    IsReplicatorDbFun = is_replicator_db_fun(),
     {ok, Notifier} = couch_db_update_notifier:start_link(fun
         ({Event, ShardDbName})
                 when Event == created; Event == updated; Event == deleted ->
             DbName = mem3:dbname(ShardDbName),
-            IsRepDb = IsReplicatorDbFun(DbName),
+            IsRepDb = is_replicator_db(DbName),
             case Event of
                 created when IsRepDb ->
                     ensure_rep_ddoc_exists(DbName);
@@ -846,7 +845,6 @@ strip_credentials({Props}) ->
 scan_all_dbs(Server) when is_pid(Server) ->
     {ok, Db} = mem3_util:ensure_exists(config:get("mem3", "shard_db", "dbs")),
     ChangesFun = couch_changes:handle_changes(#changes_args{}, nil, Db),
-    IsReplicatorDbFun = is_replicator_db_fun(),
     ChangesFun(fun({change, {Change}, _}, _) ->
         DbName = get_json_value(<<"id">>, Change),
         case DbName of <<"_design/", _/binary>> -> ok; _Else ->
@@ -854,7 +852,7 @@ scan_all_dbs(Server) when is_pid(Server) ->
             true ->
                 ok;
             false ->
-                case IsReplicatorDbFun(DbName) of
+                case is_replicator_db(DbName) of
                     true ->
                         ensure_rep_ddoc_exists(DbName),
                         gen_server:call(Server, {resume_scan, DbName});
@@ -867,15 +865,13 @@ scan_all_dbs(Server) when is_pid(Server) ->
     end),
     couch_db:close(Db).
 
-is_replicator_db_fun() ->
-    fun(Name) ->
-        DbName = mem3:dbname(Name),
-        case lists:last(binary:split(DbName, <<"/">>, [global])) of
-            <<"_replicator">> ->
-                true;
-            _ ->
-                false
-        end
+is_replicator_db(Name) ->
+    DbName = mem3:dbname(Name),
+    case lists:last(binary:split(DbName, <<"/">>, [global])) of
+        <<"_replicator">> ->
+            true;
+        _ ->
+            false
     end.
 
 get_json_value(Key, Props) ->


Mime
View raw message