This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git commit e63cae6346dcf0950f7ad759dacb9f496da5a813 Author: jcouteau <couteau@codelutin.com> Date: Thu Aug 29 12:04:52 2019 +0200 Fix slow email showing --- .../faxtomail/ui/swing/util/FaxToMailUIUtil.java | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java index f06c0351..322016c3 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/util/FaxToMailUIUtil.java @@ -997,16 +997,16 @@ public final class FaxToMailUIUtil extends ApplicationUIUtil { log.debug("Mapping attachment id " + key + " to file " + file.toURI()); } } - //remove the height, width and style on elements as that can force big width with no horizontal scroll on rendering, cf. #10344 - content = content.replaceAll("(.+) width=([\"])(.+)([\"])", "$1"); - content = content.replaceAll("(.+) width=(['])(.+)(['])", "$1"); - content = content.replaceAll("(.+) height=([\"])(.+)([\"])", "$1"); - content = content.replaceAll("(.+) height=(['])(.+)(['])", "$1"); - content = content.replaceAll("(.+) style=([\"])(.+)([\"])", "$1"); - content = content.replaceAll("(.+) style=(['])(.+)(['])", "$1"); - //remove as that can force big width with no horizontal scroll on rendering, cf. #10344 - content = content.replaceAll(" ",""); + StringBuilder builder = new StringBuilder(content); + replaceAll(builder, "(.+) width=([\"])(.+)([\"])", "$1"); + replaceAll(builder, "(.+) width=(['])(.+)(['])", "$1"); + replaceAll(builder, "(.+) height=([\"])(.+)([\"])", "$1"); + replaceAll(builder, "(.+) height=(['])(.+)(['])", "$1"); + replaceAll(builder, "(.+) style=([\"])(.+)([\"])", "$1"); + replaceAll(builder, "(.+) style=(['])(.+)(['])", "$1"); + replaceAll(builder, " ",""); + content = builder.toString(); if (log.isTraceEnabled()) { log.trace("Content after mail = " + content); @@ -1036,6 +1036,16 @@ public final class FaxToMailUIUtil extends ApplicationUIUtil { } } + /* Faster method to replace String.replaceAll (More thant 30 time faster on some emails)*/ + public static void replaceAll(StringBuilder builder, String from, String to) { + int index = builder.indexOf(from); + while (index != -1) { + builder.replace(index, index + from.length(), to); + index += to.length(); // Move to the end of the replacement + index = builder.indexOf(from, index); + } + } + protected static JTextPane createHtmlTextPane() { JTextPane textPane = new JTextPane(); textPane.setEditable(false); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.