You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2021/05/25 07:32:20 UTC
[james-mime4j] 05/05: [REFACTORING] Pre-compile
ContentLocationFieldImpl REGEX
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-mime4j.git
commit e5a2caca4d3b5b2694d7156cd42cb8e3f96541c4
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon May 24 18:50:27 2021 +0700
[REFACTORING] Pre-compile ContentLocationFieldImpl REGEX
Using String::replaceAll leads to recompile the regex on each calls.
---
.../java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java b/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java
index 790dae1..aa27b00 100644
--- a/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java
+++ b/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java
@@ -20,6 +20,7 @@
package org.apache.james.mime4j.field;
import java.io.StringReader;
+import java.util.regex.Pattern;
import org.apache.james.mime4j.codec.DecodeMonitor;
import org.apache.james.mime4j.dom.FieldParser;
@@ -32,6 +33,7 @@ import org.apache.james.mime4j.stream.Field;
* Represents a <code>Content-Location</code> field.
*/
public class ContentLocationFieldImpl extends AbstractField implements ContentLocationField {
+ private static final Pattern PATTERN = Pattern.compile("\\s");
private boolean parsed = false;
private String location;
@@ -56,7 +58,7 @@ public class ContentLocationFieldImpl extends AbstractField implements ContentLo
* remaining material is the URL string.
* Read more: http://www.faqs.org/rfcs/rfc2017.html#ixzz0aufO9nRL
*/
- location = parser.parse().replaceAll("\\s", "");
+ location = PATTERN.matcher(parser.parse()).replaceAll("");
} catch (ParseException ex) {
parseException = ex;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org