Skip to content

Commit c36898d

Browse files
committed
RUBY-1028: Improve performance of cursor reply upconverter
1 parent 97a51e1 commit c36898d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/mongo/protocol/reply.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,21 @@ def command
141141
private
142142

143143
def batch_field
144-
starting_from > 0 ? :nextBatch : :firstBatch
144+
starting_from > 0 ? 'nextBatch' : 'firstBatch'
145145
end
146146

147147
def command?
148148
!documents.empty? && documents.first.key?('ok')
149149
end
150150

151151
def find_command
152-
BSON::Document.new(
153-
ok: 1,
154-
cursor: BSON::Document.new(id: cursor_id, batch_field => documents)
155-
)
152+
document = BSON::Document.new
153+
cursor_document = BSON::Document.new
154+
cursor_document.store('id', cursor_id)
155+
cursor_document.store(batch_field, documents)
156+
document.store('ok', 1)
157+
document.store('cursor', cursor_document)
158+
document
156159
end
157160

158161
def op_command

0 commit comments

Comments
 (0)