From 9a7a353d0e0fa00137130f2dc6f0cce3a9df59bd Mon Sep 17 00:00:00 2001 From: luccioman Date: Wed, 28 Feb 2018 07:49:40 +0100 Subject: [PATCH] Removed some unnecessary intermediate list creation on array copy. --- source/net/yacy/document/Document.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/net/yacy/document/Document.java b/source/net/yacy/document/Document.java index 2a13b6a28..899b74e59 100644 --- a/source/net/yacy/document/Document.java +++ b/source/net/yacy/document/Document.java @@ -34,8 +34,8 @@ import java.io.Writer; import java.net.MalformedURLException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -130,11 +130,15 @@ public class Document { this.charset = charset; this.parserObject = parserObject; this.keywords = new LinkedHashSet(); - if (keywords != null) this.keywords.addAll(Arrays.asList(keywords)); + if (keywords != null) { + Collections.addAll(this.keywords, keywords); + } this.titles = (titles == null) ? new ArrayList(1) : titles; this.creator = (author == null) ? new StringBuilder(0) : new StringBuilder(author); this.sections = new LinkedList() ; - if (sections != null) this.sections.addAll(Arrays.asList(sections)); + if (sections != null) { + Collections.addAll(this.sections, sections); + } this.descriptions = (abstrcts == null) ? new ArrayList() : abstrcts; if (lat >= -90.0d && lat <= 90.0d && lon >= -180.0d && lon <= 180.0d) { this.lon = lon; @@ -1016,8 +1020,8 @@ dc_rights } titles.addAll(doc.titles()); - sectionTitles.addAll(Arrays.asList(doc.getSectionTitles())); - for (String d: doc.dc_description()) descriptions.add(d); + Collections.addAll(sectionTitles, doc.getSectionTitles()); + Collections.addAll(descriptions, doc.dc_description()); if (doc.getTextLength() > 0) { if (docTextLength > 0) content.write('\n');