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

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


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

commit af26c3c3259d5c08fcdfbd1e040583181b2bc055
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