From c193a02023323466e62d7c548d92fe295141c7ca Mon Sep 17 00:00:00 2001 From: reger Date: Mon, 21 Apr 2014 17:16:06 +0200 Subject: [PATCH] defer creation of new ArrayList after possible early return (to skip not used object allocation) --- source/net/yacy/peers/Protocol.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.java index 03af2b969..78c605709 100644 --- a/source/net/yacy/peers/Protocol.java +++ b/source/net/yacy/peers/Protocol.java @@ -1134,12 +1134,11 @@ public final class Protocol { } // evaluate result - List container = new ArrayList(); - if (docList == null || docList[0].size() == 0) { - Network.log.info("SEARCH (solr), returned 0 out of 0 documents from " + (target == null ? "shard" : ("peer " + target.hash + ":" + target.getName())) + " query = " + solrQuery.toString()) ; - return 0; - } - + if (docList == null || docList[0].size() == 0) { + Network.log.info("SEARCH (solr), returned 0 out of 0 documents from " + (target == null ? "shard" : ("peer " + target.hash + ":" + target.getName())) + " query = " + solrQuery.toString()) ; + return 0; + } + List container = new ArrayList(); Network.log.info("SEARCH (solr), returned " + docList[0].size() + " out of " + docList[0].getNumFound() + " documents and " + facets.size() + " facets " + facets.keySet().toString() + " from " + (target == null ? "shard" : ("peer " + target.hash + ":" + target.getName()))); int term = count; Collection docs = new ArrayList(docList[0].size());