You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuweni.apache.org by GitBox <gi...@apache.org> on 2021/06/09 06:35:44 UTC

[GitHub] [incubator-tuweni] sudo-update commented on a change in pull request #274: Return first hit, simplify code

sudo-update commented on a change in pull request #274:
URL: https://github.com/apache/incubator-tuweni/pull/274#discussion_r648006868



##########
File path: eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainIndex.kt
##########
@@ -483,10 +483,8 @@ class BlockchainIndex(private val indexWriter: IndexWriter) : BlockchainIndexWri
       val topDocs = searcher!!.search(query, HITS)
 
       val docs = mutableListOf<Document>()
-      for (hit in topDocs.scoreDocs) {
-        val doc = searcher.doc(hit.doc, setOf("_id") + fields)
-        docs += doc
-      }
+      val doc = searcher.doc(topDocs.scoreDocs.elementAt(0).doc, setOf("_id") + fields)
+      docs += doc

Review comment:
       It will change the return type from List<Document> to a single Document, is that okay?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tuweni.apache.org
For additional commands, e-mail: dev-help@tuweni.apache.org