commit e8439f0069fef96870f440f21e6beccb3c944c78
Author: Chris Rimes <[email protected]>
AuthorDate: Thu, 24 Apr 2014 21:28:06 +0100
Commit: Mauro Talevi <[email protected]>
CommitDate: Thu, 5 Jun 2014 08:16:28 +0100
JBEHAVE-1023: Lazily create the StepMatcher in the StepCandidate, as
recreating and recompiling the regex pattern every time is insanely expensive.
diff --git
a/org.jbehave.eclipse/src/org/jbehave/eclipse/editor/step/StepCandidate.java
b/org.jbehave.eclipse/src/org/jbehave/eclipse/editor/step/StepCandidate.java
index c9dfea6..2d48ff2 100644
--- a/org.jbehave.eclipse/src/org/jbehave/eclipse/editor/step/StepCandidate.java
+++ b/org.jbehave.eclipse/src/org/jbehave/eclipse/editor/step/StepCandidate.java
@@ -22,6 +22,7 @@ public class StepCandidate {
public final Integer priority;
private ParametrizedStep parametrizedStep;
private StepPatternParser stepParser;
+ private StepMatcher matcher;
public StepCandidate(LocalizedStepSupport localizedSupport,
String parameterPrefix, IMethod method,
@@ -73,7 +74,7 @@ public class StepCandidate {
}
public boolean matches(String stepWithoutKeyword) {
- return matcher(stepType,
stepPattern).matches(stepWithoutKeyword);
+ return matcher().matches(stepWithoutKeyword);
}
public String toString() {
@@ -97,8 +98,11 @@ public class StepCandidate {
return builder.toString();
}
- private StepMatcher matcher(StepType stepType, String stepPattern) {
- return stepParser.parseStep(stepType, stepPattern);
+ private StepMatcher matcher() {
+ if (matcher == null) {
+ matcher = stepParser.parseStep(stepType, stepPattern);
+ }
+ return matcher;
}
}
\ No newline at end of file