Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored all add() calls from SortedSet to only pass single values #203

Merged
merged 2 commits into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,15 @@ lunr.Index.prototype.add = function (doc, emitEvent) {
var fieldTokens = this.pipeline.run(lunr.tokenizer(doc[field.name]))

docTokens[field.name] = fieldTokens
lunr.SortedSet.prototype.add.apply(allDocumentTokens, fieldTokens)

for (var i = 0; i < fieldTokens.length; i++) {
var token = fieldTokens[i]
allDocumentTokens.add(token)
this.corpusTokens.add(token)
}
}, this)

this.documentStore.set(docRef, allDocumentTokens)
lunr.SortedSet.prototype.add.apply(this.corpusTokens, allDocumentTokens.toArray())

for (var i = 0; i < allDocumentTokens.length; i++) {
var token = allDocumentTokens.elements[i]
Expand Down
4 changes: 3 additions & 1 deletion lib/sorted_set.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ lunr.SortedSet.prototype.union = function (otherSet) {

unionSet = longSet.clone()

unionSet.add.apply(unionSet, shortSet.toArray())
for(var i = 0, shortSetElements = shortSet.toArray(); i < shortSetElements.length; i++){
unionSet.add(shortSetElements[i]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny nitpick - none of the other code includes explicitly semicolons. We should probably try and match that style.

}

return unionSet
}
Expand Down