[jruby-joni] 107/223: Make ExactMB3N opcode use string templates.

Hideki Yamane henrich at moszumanska.debian.org
Mon Nov 16 11:21:56 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 f5e29df29e754791ca4941344590521eb40c74d6
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date:   Mon Feb 20 03:30:26 2012 +0100

    Make ExactMB3N opcode use string templates.
---
 src/org/joni/ArrayCompiler.java   |  2 +-
 src/org/joni/ByteCodeMachine.java | 29 ++++++++++++++++++++++-------
 src/org/joni/ByteCodePrinter.java | 12 ++++++++++--
 3 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/src/org/joni/ArrayCompiler.java b/src/org/joni/ArrayCompiler.java
index fed29c5..17e8dc1 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 || op == OPCode.EXACTMBN;
+        return isNeedStrLenOpExact(op);
     }
 
     private int selectStrOpcode(int mbLength, int strLength, boolean ignoreCase) {
diff --git a/src/org/joni/ByteCodeMachine.java b/src/org/joni/ByteCodeMachine.java
index fbe5956..db4d6a2 100644
--- a/src/org/joni/ByteCodeMachine.java
+++ b/src/org/joni/ByteCodeMachine.java
@@ -553,14 +553,29 @@ class ByteCodeMachine extends StackMachine {
         int tlen = code[ip++];
         if (tlen * 3 > range) {opFail(); return;}
 
-        while (tlen-- > 0) {
-            if (code[ip] != bytes[s]) {opFail(); return;}
-            ip++; s++;
-            if (code[ip] != bytes[s]) {opFail(); return;}
-            ip++; s++;
-            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 (tlen-- > 0) {
+                if (bs[ps] != bytes[s]) {opFail(); return;}
+                ps++; s++;
+                if (bs[ps] != bytes[s]) {opFail(); return;}
+                ps++; s++;
+                if (bs[ps] != bytes[s]) {opFail(); return;}
+                ps++; s++;
+            }
+        } else {
+            while (tlen-- > 0) {
+                if (code[ip] != bytes[s]) {opFail(); return;}
+                ip++; s++;
+                if (code[ip] != bytes[s]) {opFail(); return;}
+                ip++; s++;
+                if (code[ip] != bytes[s]) {opFail(); return;}
+                ip++; s++;
+            }
         }
+
         sprev = s - 3;
     }
 
diff --git a/src/org/joni/ByteCodePrinter.java b/src/org/joni/ByteCodePrinter.java
index 112a2ec..77938da 100644
--- a/src/org/joni/ByteCodePrinter.java
+++ b/src/org/joni/ByteCodePrinter.java
@@ -196,8 +196,16 @@ class ByteCodePrinter {
             case OPCode.EXACTMB3N:
                 len = code[bp];
                 bp += OPSize.LENGTH;
-                pLenString(sb, len, 3, bp);
-                bp += len * 3;
+                if (Config.USE_STRING_TEMPLATES) {
+                    tm = code[bp];
+                    bp += OPSize.INDEX;
+                    idx = code[bp];
+                    bp += OPSize.INDEX;
+                    pLenStringFromTemplate(sb, len, 3, templates[tm], idx);
+                } else {
+                    pLenString(sb, len, 3, bp);
+                    bp += len * 3;
+                }
                 break;
 
             case OPCode.EXACTMBN:

-- 
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