You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@any23.apache.org by ha...@apache.org on 2021/04/23 14:01:03 UTC

[any23] branch master updated: [ANY23-465] StringBuilder is used instead of String concatenation at loop due to performance reasons.

This is an automated email from the ASF dual-hosted git repository.

hansbrende pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/any23.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b906fa  [ANY23-465] StringBuilder is  used instead of String concatenation at loop due to performance reasons.
     new 09e4322  Merge pull request #172 from kamaci/fix/performance_string_concatenation
1b906fa is described below

commit 1b906fa9ff39519ec1331533a0f9ba01f4913572
Author: kamaci <fu...@gmail.com>
AuthorDate: Tue Apr 20 22:24:57 2021 +0300

    [ANY23-465] StringBuilder is  used instead of String concatenation at loop due to performance reasons.
---
 .../src/main/java/org/apache/any23/extractor/html/HTMLDocument.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/any23/extractor/html/HTMLDocument.java b/core/src/main/java/org/apache/any23/extractor/html/HTMLDocument.java
index 9d4d208..9a35807 100644
--- a/core/src/main/java/org/apache/any23/extractor/html/HTMLDocument.java
+++ b/core/src/main/java/org/apache/any23/extractor/html/HTMLDocument.java
@@ -75,10 +75,10 @@ public class HTMLDocument {
         // first check if there are values inside
         List<Node> values = DomUtils.findAllByClassName(node, "value");
         if (!values.isEmpty()) {
-            String val = "";
+            StringBuilder val = new StringBuilder();
             for (Node n : values)
-                val += n.getTextContent();
-            return new TextField(val.trim(), node);
+                val.append(n.getTextContent());
+            return new TextField(val.toString().trim(), node);
         }
         if ("ABBR".equals(name) && (null != attributes.getNamedItem("title"))) {
             result = new TextField(attributes.getNamedItem("title").getNodeValue(), node);