Skip to content
Snippets Groups Projects
Commit 7c643018 authored by Guylaine Prat's avatar Guylaine Prat
Browse files

Optimize use of regex pattern

parent 90c1d42a
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ import java.util.List; ...@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.NavigableMap; import java.util.NavigableMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.regex.Pattern;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.hipparchus.analysis.differentiation.DerivativeStructure; import org.hipparchus.analysis.differentiation.DerivativeStructure;
...@@ -272,6 +273,13 @@ public class DumpReplayer { ...@@ -272,6 +273,13 @@ public class DumpReplayer {
/** Dumped calls. */ /** Dumped calls. */
private final List<DumpedCall> calls; private final List<DumpedCall> calls;
/** Pattern for delimiting regular expressions. */
private static final Pattern SEPARATOR = Pattern.compile("\\s+");
/** Empty pattern. */
private static final Pattern PATTERN = Pattern.compile(" ");
/** Simple constructor. /** Simple constructor.
*/ */
public DumpReplayer() { public DumpReplayer() {
...@@ -976,14 +984,14 @@ public class DumpReplayer { ...@@ -976,14 +984,14 @@ public class DumpReplayer {
final int colon = line.indexOf(':'); final int colon = line.indexOf(':');
if (colon > 0) { if (colon > 0) {
final String parsedKey = line.substring(0, colon).trim().replaceAll(" ", "_").toUpperCase(); final String parsedKey = PATTERN.matcher(line.substring(0, colon).trim()).replaceAll("_").toUpperCase();
try { try {
final LineParser parser = LineParser.valueOf(parsedKey); final LineParser parser = LineParser.valueOf(parsedKey);
final String[] fields; final String[] fields;
if (colon + 1 >= line.length()) { if (colon + 1 >= line.length()) {
fields = new String[0]; fields = new String[0];
} else { } else {
fields = line.substring(colon + 1).trim().split("\\s+"); fields = SEPARATOR.split(line.substring(colon + 1).trim());
} }
parser.parse(l, file, line, fields, global); parser.parse(l, file, line, fields, global);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment