couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [01/50] couch commit: updated refs/heads/master to 9d0ac7d
Date Thu, 28 Aug 2014 12:11:37 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master e696e4399 -> 9d0ac7d34


Remove unnecessary btree lookup

This commit removes an unnecessary btree lookup in couch_db_updater. As
far as I can tell, its reason for existence was removed in 2010, but the
btree lookup wasn't.

BugzID: 23737


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

Branch: refs/heads/master
Commit: 3483d90bfb2cf2679af3f0e36acedcf02fb65e0d
Parents: 74358fc
Author: Benjamin Bastian <benjamin.bastian@gmail.com>
Authored: Thu Sep 26 15:40:40 2013 -0700
Committer: Robert Newson <rnewson@apache.org>
Committed: Thu Aug 28 12:59:59 2014 +0100

----------------------------------------------------------------------
 src/couch_db_updater.erl | 40 +++++++++++++---------------------------
 1 file changed, 13 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/3483d90b/src/couch_db_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_db_updater.erl b/src/couch_db_updater.erl
index 7c2a43a..e01df83 100644
--- a/src/couch_db_updater.erl
+++ b/src/couch_db_updater.erl
@@ -771,10 +771,8 @@ update_docs_int(Db, DocsList, NonRepDocs, MergeConflicts, FullCommit)
->
 update_local_docs(Db, []) ->
     {ok, Db};
 update_local_docs(#db{local_tree=Btree}=Db, Docs) ->
-    Ids = [Id || {_Client, #doc{id=Id}} <- Docs],
-    OldDocLookups = couch_btree:lookup(Btree, Ids),
-    BtreeEntries = lists:zipwith(
-        fun({Client, NewDoc}, _OldDocLookup) ->
+    BtreeEntries = lists:map(
+        fun({Client, NewDoc}) ->
             #doc{
                 id = Id,
                 deleted = Delete,
@@ -787,29 +785,17 @@ update_local_docs(#db{local_tree=Btree}=Db, Docs) ->
             [] ->
                 PrevRev = 0
             end,
-            %% disabled conflict checking for local docs -- APK 16 June 2010
-            % OldRev =
-            % case OldDocLookup of
-            %     {ok, {_, {OldRev0, _}}} -> OldRev0;
-            %     not_found -> 0
-            % end,
-            % case OldRev == PrevRev of
-            % true ->
-                case Delete of
-                    false ->
-                        send_result(Client, NewDoc, {ok,
-                                {0, ?l2b(integer_to_list(PrevRev + 1))}}),
-                        {update, {Id, {PrevRev + 1, Body}}};
-                    true  ->
-                        send_result(Client, NewDoc,
-                                {ok, {0, <<"0">>}}),
-                        {remove, Id}
-                end%;
-            % false ->
-            %     send_result(Client, Ref, conflict),
-            %     ignore
-            % end
-        end, Docs, OldDocLookups),
+            case Delete of
+                false ->
+                    send_result(Client, NewDoc, {ok,
+                        {0, ?l2b(integer_to_list(PrevRev + 1))}}),
+                    {update, {Id, {PrevRev + 1, Body}}};
+                true  ->
+                    send_result(Client, NewDoc,
+                        {ok, {0, <<"0">>}}),
+                    {remove, Id}
+            end
+        end, Docs),
 
     BtreeIdsRemove = [Id || {remove, Id} <- BtreeEntries],
     BtreeIdsUpdate = [{Key, Val} || {update, {Key, Val}} <- BtreeEntries],


Mime
View raw message