Skip to content

Commit 4fb8426

Browse files
committed
Cache resolved Fix file path to improve include() performance. (#287)
- includeBenchmarkBase1: 3.3080 +/- 0.0558 - includeBenchmarkBase1000: 3.4018 +/- 0.0212 - includeBenchmarkBase100000: 5.4032 +/- 0.0494 - includeBenchmarkSome1: 3.7932 +/- 0.1135 - includeBenchmarkSome1000: 3.8172 +/- 0.0428 - includeBenchmarkSome100000: 6.1055 +/- 0.1947 - includeBenchmarkMany1: 5.2958 +/- 0.2262 - includeBenchmarkMany1000: 5.3335 +/- 0.3680 - includeBenchmarkMany100000: 7.7365 +/- 0.1504
1 parent 4ddfcac commit 4fb8426

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

metafix/src/main/java/org/metafacture/metafix/Metafix.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class Metafix implements StreamPipe<StreamReceiver>, Maps { // checkstyle
7979
private final Map<String, Map<String, String>> maps = new HashMap<>();
8080
private final Map<String, RecordTransformer> fixCache = new HashMap<>();
8181
private final Map<String, RecordTransformer> macros = new HashMap<>();
82+
private final Map<String, String> pathCache = new HashMap<>();
8283
private final Map<String, String> vars = new HashMap<>();
8384
private final RecordTransformer recordTransformer;
8485
private final StreamFlattener flattener = new StreamFlattener();
@@ -149,6 +150,10 @@ public void literal(final String name, final String value) {
149150
}
150151

151152
public String resolvePath(final String path) {
153+
return pathCache.computeIfAbsent(path, this::resolvePathInternal);
154+
}
155+
156+
private String resolvePathInternal(final String path) {
152157
final String resolvedPath;
153158

154159
if (isValidUrl(path)) {

0 commit comments

Comments
 (0)