You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2017/04/12 15:49:46 UTC
[couchdb] branch 63012-scheduler updated: [fixup] use throw for
early return from ets:foldl
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch 63012-scheduler
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/63012-scheduler by this push:
new 8aea44f [fixup] use throw for early return from ets:foldl
8aea44f is described below
commit 8aea44faf718ccd190318e0f6c767d8fae92956a
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Wed Apr 12 11:49:40 2017 -0400
[fixup] use throw for early return from ets:foldl
---
.../src/couch_replicator_doc_processor.erl | 23 +++++++++++-----------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/couch_replicator/src/couch_replicator_doc_processor.erl b/src/couch_replicator/src/couch_replicator_doc_processor.erl
index e438902..40c6cfe 100644
--- a/src/couch_replicator/src/couch_replicator_doc_processor.erl
+++ b/src/couch_replicator/src/couch_replicator_doc_processor.erl
@@ -514,20 +514,19 @@ docs(States) ->
-spec doc(binary(), binary()) -> {ok, {[_]}} | {error, not_found}.
doc(Db, DocId) ->
HealthThreshold = couch_replicator_scheduler:health_threshold(),
- Res = ets:foldl(fun(_RDoc, [_] = Acc) -> Acc;
- (RDoc, []) ->
- {Shard, RDocId} = RDoc#rdoc.id,
- case {mem3:dbname(Shard), RDocId} of
- {Db, DocId} ->
- [ejson_doc(RDoc, HealthThreshold)];
- {_OtherDb, _OtherDocId} ->
- []
- end
- end, [], ?MODULE),
+ Res = (catch ets:foldl(fun(RDoc, nil) ->
+ {Shard, RDocId} = RDoc#rdoc.id,
+ case {mem3:dbname(Shard), RDocId} of
+ {Db, DocId} ->
+ throw({found, ejson_doc(RDoc, HealthThreshold)});
+ {_OtherDb, _OtherDocId} ->
+ nil
+ end
+ end, nil, ?MODULE)),
case Res of
- [DocInfo] ->
+ {found, DocInfo} ->
{ok, DocInfo};
- [] ->
+ nil ->
{error, not_found}
end.
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].