groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 08/23: GROOVY-9276: Improve the performance of parsing
Date Fri, 11 Oct 2019 13:54:21 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 28600276c01af32431cdc55340e0f9c03fe94a2d
Author: Daniel.Sun <realbluesun@hotmail.com>
AuthorDate: Fri Oct 11 08:07:04 2019 +0800

    GROOVY-9276: Improve the performance of parsing
    
    (cherry picked from commit 28ae0c4f0ac9764c08bce8064cfb1983723cde98)
---
 .../apache/groovy/parser/antlr4/GroovyLangParser.java | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangParser.java
b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangParser.java
index 0b87657..8e2c41a 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangParser.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangParser.java
@@ -19,6 +19,8 @@
 
 package org.apache.groovy.parser.antlr4;
 
+import org.antlr.v4.runtime.FailedPredicateException;
+import org.antlr.v4.runtime.Parser;
 import org.antlr.v4.runtime.TokenStream;
 import org.antlr.v4.runtime.atn.ParserATNSimulator;
 import org.apache.groovy.parser.antlr4.internal.atnmanager.ParserAtnManager;
@@ -40,4 +42,21 @@ public class GroovyLangParser extends GroovyParser {
         }
     }
 
+    @Override
+    protected FailedPredicateException createFailedPredicateException(String predicate, String
message) {
+        return new LightWeightFailedPredicateException(this, predicate, message);
+    }
+
+    private static class LightWeightFailedPredicateException extends FailedPredicateException
{
+        public LightWeightFailedPredicateException(Parser recognizer, String predicate, String
message) {
+            super(recognizer, predicate, message);
+        }
+
+        @Override
+        public Throwable fillInStackTrace() {
+            // `FailedPredicateException` is used to change the control flow,
+            // so its stack trace can be eliminated for better performance
+            return this;
+        }
+    }
 }


Mime
View raw message