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

tilman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 469cd40c0 TIKA-4290 Replaced string concatenation in loop - for every 
loop previously a StringBuilder was implicitly created. It's performance 
related (#1900)
469cd40c0 is described below

commit 469cd40c058c5de4269cd5f8ea8d88adb9008922
Author: Dmitry Kryukov <d...@users.noreply.github.com>
AuthorDate: Wed Aug 14 10:29:30 2024 +0300

    TIKA-4290 Replaced string concatenation in loop - for every loop previously 
a StringBuilder was implicitly created. It's performance related (#1900)
---
 .../org/apache/tika/langdetect/tika/LanguageIdentifier.java | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git 
a/tika-langdetect/tika-langdetect-tika/src/main/java/org/apache/tika/langdetect/tika/LanguageIdentifier.java
 
b/tika-langdetect/tika-langdetect-tika/src/main/java/org/apache/tika/langdetect/tika/LanguageIdentifier.java
index 8ff9f40c3..81c01a56c 100644
--- 
a/tika-langdetect/tika-langdetect-tika/src/main/java/org/apache/tika/langdetect/tika/LanguageIdentifier.java
+++ 
b/tika-langdetect/tika-langdetect-tika/src/main/java/org/apache/tika/langdetect/tika/LanguageIdentifier.java
@@ -141,7 +141,7 @@ public class LanguageIdentifier {
     public static void initProfiles() {
         clearProfiles();
 
-        errors = "";
+        StringBuilder stringBuilder = new StringBuilder();
         InputStream stream;
         stream = 
LanguageIdentifier.class.getResourceAsStream(PROPERTIES_OVERRIDE_FILE);
         if (stream == null) {
@@ -153,8 +153,9 @@ public class LanguageIdentifier {
                 props = new Properties();
                 props.load(stream);
             } catch (IOException e) {
-                errors += "IOException while trying to load property file. 
Message: " +
-                        e.getMessage() + "\n";
+                stringBuilder.append("IOException while trying to load 
property file. Message: ")
+                        .append(e.getMessage())
+                        .append("\n");
             }
         }
 
@@ -165,10 +166,12 @@ public class LanguageIdentifier {
             try {
                 addProfile(language);
             } catch (Exception e) {
-                errors += "Language " + language + " (" + name + ") not 
initialized. Message: " +
-                        e.getMessage() + "\n";
+                stringBuilder.append("Language ").append(language).append(" 
(").append(name)
+                        .append(") not initialized. Message: ")
+                        .append(e.getMessage()).append("\n");
             }
         }
+        errors = stringBuilder.toString();
     }
 
     /**

Reply via email to