tmf: replace find() with matches() in CustomTxtTrace.java
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 27 Feb 2014 20:09:57 +0000 (15:09 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 14 Mar 2014 20:47:47 +0000 (16:47 -0400)
This should provide a nice performance boost and make the regexes less
ambiguous.

With matches, the reader will match per line instead of searching for a
match. this can save up to an order of magnitude in reading.

Change-Id: I267426a9f2ab672590e35edafef2913ac32ac8f2
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/22637

org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java

index 59dcf3b07cd43b2b82f9adefc2ac6cc1d85f0648..c7d462b1c32dbc0ddbd070dcb7e52eb9b2cd2362 100644 (file)
@@ -141,7 +141,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser, ITmfPer
             while (line != null) {
                 for (final InputLine input : getFirstLines()) {
                     final Matcher matcher = input.getPattern().matcher(line);
-                    if (matcher.find()) {
+                    if (matcher.matches()) {
                         context.setLocation(new TmfLongLocation(rawPos));
                         context.firstLineMatcher = matcher;
                         context.firstLine = line;
@@ -259,7 +259,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser, ITmfPer
                 if (currentInput == null) {
                     for (final InputLine input : getFirstLines()) {
                         final Matcher matcher = input.getPattern().matcher(line);
-                        if (matcher.find()) {
+                        if (matcher.matches()) {
                             context.setLocation(new TmfLongLocation(rawPos));
                             context.firstLineMatcher = matcher;
                             context.firstLine = line;
@@ -274,7 +274,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser, ITmfPer
                         if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {
                             for (final InputLine input : getFirstLines()) {
                                 final Matcher matcher = input.getPattern().matcher(line);
-                                if (matcher.find()) {
+                                if (matcher.matches()) {
                                     context.setLocation(new TmfLongLocation(rawPos));
                                     context.firstLineMatcher = matcher;
                                     context.firstLine = line;
@@ -286,7 +286,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser, ITmfPer
                         }
                         for (final InputLine input : nextInputs) {
                             final Matcher matcher = input.getPattern().matcher(line);
-                            if (matcher.find()) {
+                            if (matcher.matches()) {
                                 event.processGroups(input, matcher);
                                 currentInput = input;
                                 if (countMap.get(currentInput) == null) {
@@ -328,7 +328,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser, ITmfPer
                     }
                     if (!processed && currentInput != null) {
                         final Matcher matcher = currentInput.getPattern().matcher(line);
-                        if (matcher.find()) {
+                        if (matcher.matches()) {
                             event.processGroups(currentInput, matcher);
                             countMap.put(currentInput, countMap.get(currentInput) + 1);
                             if (currentInput.childrenInputs != null && currentInput.childrenInputs.size() > 0) {
@@ -421,7 +421,7 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser, ITmfPer
             while ((line != null) && (lineCount++ < MAX_LINES)) {
                 for (InputLine inputLine : fDefinition.inputs) {
                     Matcher matcher = inputLine.getPattern().matcher(line);
-                    if (matcher.find()) {
+                    if (matcher.matches()) {
                         matches++;
                         break;
                     }
index 1b4195faa8e1eb83fe607db1dfa71b4ffa06a667..0eb697be9dc9caf5a119b5b3413834d571b63e5a 100644 (file)
@@ -681,7 +681,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                         continue;
                     }
                     Matcher matcher = pattern.matcher(log);
-                    if (matcher.find()) {
+                    if (matcher.matches()) {
                         rootLineMatches++;
                         inputText.setStyleRange(new StyleRange(rawPos, length,
                                 COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));
@@ -706,7 +706,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                             if (currentInput == null) {
                                 for (InputLine input : definition.inputs) {
                                     matcher = input.getPattern().matcher(log);
-                                    if (matcher.find()) {
+                                    if (matcher.matches()) {
                                         continue event;
                                     }
                                 }
@@ -716,14 +716,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                                     if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {
                                         for (InputLine input : definition.inputs) {
                                             matcher = input.getPattern().matcher(log);
-                                            if (matcher.find()) {
+                                            if (matcher.matches()) {
                                                 continue event;
                                             }
                                         }
                                     }
                                     for (InputLine input : nextInputs) {
                                         matcher = input.getPattern().matcher(log);
-                                        if (matcher.find()) {
+                                        if (matcher.matches()) {
                                             inputText.setStyleRange(new StyleRange(rawPos, length,
                                                     COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
                                             currentInput = input;
@@ -769,7 +769,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                                 }
                                 if (!processed && currentInput != null) {
                                     matcher = currentInput.getPattern().matcher(log);
-                                    if (matcher.find()) {
+                                    if (matcher.matches()) {
                                         inputText.setStyleRange(new StyleRange(rawPos, length,
                                                 COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
                                         updatePreviewLine(currentInput, matcher, data, rawPos, rootLineMatches);
This page took 0.028276 seconds and 5 git commands to generate.