Skip to content

Commit

Permalink
Bumped version to 1.1.6. Improved running time of mongrel_cursor:rest…
Browse files Browse the repository at this point in the history
…/1 and take/2 functions from O(n^2) to O(n).
  • Loading branch information
hammingweight@gmail.com committed Apr 30, 2012
1 parent 4700cd7 commit 5bdd795
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion make_mongrel.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/bash
VERSION=1.1.5
VERSION=1.1.6
BUILD_NAME=mongrel-$VERSION
set -x
mkdir $BUILD_NAME
Expand Down
2 changes: 1 addition & 1 deletion overview.edoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@author CA Meijer <hammingweight@gmail.com>
@copyright 2012 CA Meijer
@version 1.1.5
@version 1.1.6
@title Mongrel Record/Document Mapper

@doc
Expand Down
2 changes: 1 addition & 1 deletion src/mongrel.app
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, mongrel,
[{description, "MongoDB Record/Document Mapper"},
{vsn, "1.1.5"},
{vsn, "1.1.6"},
{modules, [mongrel, mongrel_app, mongrel_cursor, mongrel_mapper, mongrel_sup, mongrel_types]},
{registered, [mongrel_sup, mongrel_mapper]},
{applications, [kernel, stdlib, mongodb]},
Expand Down
10 changes: 5 additions & 5 deletions src/mongrel_cursor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -171,27 +171,27 @@ rest(State, Docs) ->
MongoCursor = State#state.mongo_cursor,
case mongo_cursor:next(MongoCursor) of
{} ->
Docs;
lists:reverse(Docs);
{Doc} ->
CallbackFunction = construct_callback_function(State),
Collection = State#state.collection,
Record = mongrel_mapper:unmap(Collection, Doc, CallbackFunction),
rest(State, Docs ++ [Record])
rest(State, [Record|Docs])
end.

% Reads documents from a cursor up to a limit and returns them as a list of records.
take(_State, 0, Docs) ->
Docs;
lists:reverse(Docs);
take(State, Limit, Docs) ->
MongoCursor = State#state.mongo_cursor,
case mongo_cursor:next(MongoCursor) of
{} ->
Docs;
lists:reverse(Docs);
{Doc} ->
CallbackFunction = construct_callback_function(State),
Collection = State#state.collection,
Record = mongrel_mapper:unmap(Collection, Doc, CallbackFunction),
take(State, Limit-1, Docs ++ [Record])
take(State, Limit-1, [Record|Docs])
end.

% Creates a function that uses connection settings to read nested documents
Expand Down

0 comments on commit 5bdd795

Please sign in to comment.