You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/06 13:55:14 UTC
[37/48] couch commit: updated refs/heads/windsor-merge-300 to 2c2f53e
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/13b4e435
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/13b4e435
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/13b4e435
Branch: refs/heads/windsor-merge-300
Commit: 13b4e4352f8b4b2d5839de7f444ad04153064094
Parents: 46607e0
Author: Benjamin Bastian <be...@gmail.com>
Authored: Thu Sep 26 15:40:40 2013 -0700
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Aug 6 11:02:12 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/13b4e435/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],