[jruby-joni] 120/279: Make EXACTMBN opcode use string tamplates.

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:27:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository jruby-joni.

commit 1f2ae1dc6174d15fdfa96d266012d3cb868b42b6
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date:   Mon Feb 20 03:14:51 2012 +0100

    Make EXACTMBN opcode use string tamplates.
---
 src/org/joni/ArrayCompiler.java   |  2 +-
 src/org/joni/ByteCodeMachine.java | 17 ++++++++++++++---
 src/org/joni/ByteCodePrinter.java | 17 +++++++++++++++--
 src/org/joni/Config.java          |  1 +
 src/org/joni/Parser.java          |  4 +---
 5 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/src/org/joni/ArrayCompiler.java b/src/org/joni/ArrayCompiler.java
index 6ac7429..fed29c5 100644
--- a/src/org/joni/ArrayCompiler.java
+++ b/src/org/joni/ArrayCompiler.java
@@ -106,7 +106,7 @@ final class ArrayCompiler extends Compiler {
     }
 
     private boolean opTemplated(int op) {
-        return op == OPCode.EXACTN || op == OPCode.EXACTMB2N || op == OPCode.EXACTN_IC || op == OPCode.EXACTN_IC_SB;
+        return op == OPCode.EXACTN || op == OPCode.EXACTMB2N || op == OPCode.EXACTN_IC || op == OPCode.EXACTN_IC_SB || op == OPCode.EXACTMBN;
     }
 
     private int selectStrOpcode(int mbLength, int strLength, boolean ignoreCase) {
diff --git a/src/org/joni/ByteCodeMachine.java b/src/org/joni/ByteCodeMachine.java
index 3e5f8fb..fbe5956 100644
--- a/src/org/joni/ByteCodeMachine.java
+++ b/src/org/joni/ByteCodeMachine.java
@@ -571,10 +571,21 @@ class ByteCodeMachine extends StackMachine {
         tlen2 *= tlen;
         if (s + tlen2 > range) {opFail(); return;}
 
-        while(tlen2-- > 0) {
-            if (code[ip] != bytes[s]) {opFail(); return;}
-            ip++; s++;
+        if (Config.USE_STRING_TEMPLATES) {
+            byte[]bs = regex.templates[code[ip++]];
+            int ps = code[ip++];
+
+            while (tlen2-- > 0) {
+                if (bs[ps] != bytes[s]) {opFail(); return;}
+                ps++; s++;
+            }
+        } else {
+            while (tlen2-- > 0) {
+                if (code[ip] != bytes[s]) {opFail(); return;}
+                ip++; s++;
+            }
         }
+
         sprev = s - tlen;
     }
 
diff --git a/src/org/joni/ByteCodePrinter.java b/src/org/joni/ByteCodePrinter.java
index 6c95149..112a2ec 100644
--- a/src/org/joni/ByteCodePrinter.java
+++ b/src/org/joni/ByteCodePrinter.java
@@ -205,9 +205,22 @@ class ByteCodePrinter {
                 bp += OPSize.LENGTH;
                 len = code[bp];
                 bp += OPSize.LENGTH;
-                sb.append(":" + mbLen + ":" + len + ":");
                 n = len * mbLen;
-                while (n-- > 0) sb.append(new String(new byte[]{(byte)code[bp++]}));
+
+                if (Config.USE_STRING_TEMPLATES) {
+                    tm = code[bp];
+                    bp += OPSize.INDEX;
+                    idx = code[bp];
+                    bp += OPSize.INDEX;
+                    sb.append(":T:" + mbLen + ":" + len + ":");
+
+                    while (n-- > 0) sb.append(new String(new byte[]{templates[tm][idx++]}));
+                } else {
+                    sb.append(":" + mbLen + ":" + len + ":");
+
+                    while (n-- > 0) sb.append(new String(new byte[]{(byte)code[bp++]}));
+                }
+
                 break;
 
             case OPCode.EXACT1_IC:
diff --git a/src/org/joni/Config.java b/src/org/joni/Config.java
index dab3565..3467966 100644
--- a/src/org/joni/Config.java
+++ b/src/org/joni/Config.java
@@ -80,6 +80,7 @@ public interface Config extends org.jcodings.Config {
     final PrintStream err = System.err;
 
     final boolean DEBUG_ALL                         = false;
+
     final boolean DEBUG                             = DEBUG_ALL;
     final boolean DEBUG_PARSE_TREE                  = DEBUG_ALL;
     final boolean DEBUG_PARSE_TREE_RAW              = true;
diff --git a/src/org/joni/Parser.java b/src/org/joni/Parser.java
index 6ee740e..a5fa50d 100644
--- a/src/org/joni/Parser.java
+++ b/src/org/joni/Parser.java
@@ -773,7 +773,6 @@ class Parser extends Lexer {
                 }
                 node = new CallNode(bytes, token.getCallNameP(), token.getCallNameEnd(), gNum);
                 env.numCall++;
-                break;
             } // USE_SUBEXP_CALL
             break;
 
@@ -790,8 +789,7 @@ class Parser extends Lexer {
                     node = new StringNode(); // node_new_empty
                 }
             } else {
-                // !goto tk_byte;!
-                return parseExpTkByte(group);
+                return parseExpTkByte(group); // goto tk_byte
             }
             break;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git



More information about the pkg-java-commits mailing list