diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/pipeline/document_source_limit.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/pipeline/document_source_limit.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_limit.cpp | 89 |
1 files changed, 40 insertions, 49 deletions
diff --git a/src/mongo/db/pipeline/document_source_limit.cpp b/src/mongo/db/pipeline/document_source_limit.cpp index 1789b689eda..9729c6bae8f 100644 --- a/src/mongo/db/pipeline/document_source_limit.cpp +++ b/src/mongo/db/pipeline/document_source_limit.cpp @@ -37,66 +37,57 @@ namespace mongo { - using boost::intrusive_ptr; +using boost::intrusive_ptr; - const char DocumentSourceLimit::limitName[] = "$limit"; +const char DocumentSourceLimit::limitName[] = "$limit"; - DocumentSourceLimit::DocumentSourceLimit(const intrusive_ptr<ExpressionContext> &pExpCtx, - long long limit) - : DocumentSource(pExpCtx) - , limit(limit) - , count(0) - {} +DocumentSourceLimit::DocumentSourceLimit(const intrusive_ptr<ExpressionContext>& pExpCtx, + long long limit) + : DocumentSource(pExpCtx), limit(limit), count(0) {} - const char *DocumentSourceLimit::getSourceName() const { - return limitName; - } - - bool DocumentSourceLimit::coalesce( - const intrusive_ptr<DocumentSource> &pNextSource) { - DocumentSourceLimit *pLimit = - dynamic_cast<DocumentSourceLimit *>(pNextSource.get()); +const char* DocumentSourceLimit::getSourceName() const { + return limitName; +} - /* if it's not another $limit, we can't coalesce */ - if (!pLimit) - return false; +bool DocumentSourceLimit::coalesce(const intrusive_ptr<DocumentSource>& pNextSource) { + DocumentSourceLimit* pLimit = dynamic_cast<DocumentSourceLimit*>(pNextSource.get()); - /* we need to limit by the minimum of the two limits */ - if (pLimit->limit < limit) - limit = pLimit->limit; - return true; - } + /* if it's not another $limit, we can't coalesce */ + if (!pLimit) + return false; - boost::optional<Document> DocumentSourceLimit::getNext() { - pExpCtx->checkForInterrupt(); + /* we need to limit by the minimum of the two limits */ + if (pLimit->limit < limit) + limit = pLimit->limit; + return true; +} - if (++count > limit) { - pSource->dispose(); - return boost::none; - } +boost::optional<Document> DocumentSourceLimit::getNext() { + pExpCtx->checkForInterrupt(); - return pSource->getNext(); + if (++count > limit) { + pSource->dispose(); + return boost::none; } - Value DocumentSourceLimit::serialize(bool explain) const { - return Value(DOC(getSourceName() << limit)); - } + return pSource->getNext(); +} - intrusive_ptr<DocumentSourceLimit> DocumentSourceLimit::create( - const intrusive_ptr<ExpressionContext> &pExpCtx, - long long limit) { - uassert(15958, "the limit must be positive", - limit > 0); - return new DocumentSourceLimit(pExpCtx, limit); - } +Value DocumentSourceLimit::serialize(bool explain) const { + return Value(DOC(getSourceName() << limit)); +} + +intrusive_ptr<DocumentSourceLimit> DocumentSourceLimit::create( + const intrusive_ptr<ExpressionContext>& pExpCtx, long long limit) { + uassert(15958, "the limit must be positive", limit > 0); + return new DocumentSourceLimit(pExpCtx, limit); +} - intrusive_ptr<DocumentSource> DocumentSourceLimit::createFromBson( - BSONElement elem, - const intrusive_ptr<ExpressionContext> &pExpCtx) { - uassert(15957, "the limit must be specified as a number", - elem.isNumber()); +intrusive_ptr<DocumentSource> DocumentSourceLimit::createFromBson( + BSONElement elem, const intrusive_ptr<ExpressionContext>& pExpCtx) { + uassert(15957, "the limit must be specified as a number", elem.isNumber()); - long long limit = elem.numberLong(); - return DocumentSourceLimit::create(pExpCtx, limit); - } + long long limit = elem.numberLong(); + return DocumentSourceLimit::create(pExpCtx, limit); +} } |