Skip to content

Commit cf3dfee

Browse files
Yann Simonchkal
authored andcommitted
when no EL is needed, cache the mapping for the input URL
1 parent 8720884 commit cf3dfee

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎core/src/main/java/com/ocpsoft/pretty/faces/config/PrettyConfig.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
import java.util.ArrayList;
2020
import java.util.Collections;
21+
import java.util.HashMap;
2122
import java.util.List;
23+
import java.util.Map;
2224

2325
import com.ocpsoft.pretty.PrettyContext;
2426
import com.ocpsoft.pretty.PrettyFilter;
@@ -32,6 +34,7 @@ public class PrettyConfig
3234
private List<UrlMapping> mappings = new ArrayList<UrlMapping>();
3335
private List<RewriteRule> globalRewriteRules = new ArrayList<RewriteRule>();
3436
private String dynaviewId = "";
37+
private Map<String, UrlMapping> cachedMappings = new HashMap<String, UrlMapping>();
3538

3639
/**
3740
* Set the current DynaView ID. This is used when calculating dynamic viewIds specified in pretty-config.xml (Do not
@@ -91,10 +94,17 @@ public void setMappings(final List<UrlMapping> mappings)
9194
*/
9295
public UrlMapping getMappingForUrl(final URL url)
9396
{
97+
final String mappingKey = url.toURL();
98+
if (cachedMappings.containsKey(mappingKey)) {
99+
return cachedMappings.get(mappingKey);
100+
}
94101
for (UrlMapping mapping : getMappings())
95102
{
96103
if (mapping.matches(url))
97104
{
105+
if (!mapping.getPatternParser().isElPattern()) {
106+
cachedMappings.put(mappingKey, mapping);
107+
}
98108
return mapping;
99109
}
100110
}

0 commit comments

Comments
 (0)