[jruby-joni] 119/194: stack code cleanup
Hideki Yamane
henrich at moszumanska.debian.org
Thu Feb 1 12:04:33 UTC 2018
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 de3cc5418fdfbe30fa6e07c9b119f909c0bfe890
Author: Marcin Mielzynski <lopx at gazeta.pl>
Date: Mon Jan 8 19:51:42 2018 +0100
stack code cleanup
---
src/org/joni/ByteCodeMachine.java | 2 +-
src/org/joni/StackMachine.java | 40 ++++++++++++++-------------------------
2 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/src/org/joni/ByteCodeMachine.java b/src/org/joni/ByteCodeMachine.java
index 0fa26b4..bc18b0e 100644
--- a/src/org/joni/ByteCodeMachine.java
+++ b/src/org/joni/ByteCodeMachine.java
@@ -179,7 +179,7 @@ class ByteCodeMachine extends StackMachine {
ip = 0;
if (Config.DEBUG_MATCH) debugMatchBegin();
- init();
+ stastackInit();
bestLen = -1;
s = _sstart;
diff --git a/src/org/joni/StackMachine.java b/src/org/joni/StackMachine.java
index f7fe7eb..69af0a3 100644
--- a/src/org/joni/StackMachine.java
+++ b/src/org/joni/StackMachine.java
@@ -32,13 +32,10 @@ abstract class StackMachine extends Matcher implements StackType {
protected StackEntry[]stack;
protected int stk; // stkEnd
-
protected final int[]repeatStk;
protected final int memStartStk, memEndStk;
-
- // CEC
- protected byte[] stateCheckBuff; // move to int[] ?
- int stateCheckBuffSize;
+ protected byte[] stateCheckBuff; // CEC, move to int[] ?
+ protected int stateCheckBuffSize;
protected StackMachine(Regex regex, byte[]bytes, int p , int end) {
super(regex, bytes, p, end);
@@ -58,6 +55,15 @@ abstract class StackMachine extends Matcher implements StackType {
repeatStk = n > 0 ? new int[n] : null;
}
+ protected final void stastackInit() {
+ if (stack != null) pushEnsured(ALT, regex.codeLength - 1); /* bottom stack */
+ if (repeatStk != null) {
+ for (int i = (Config.USE_SUBEXP_CALL ? 0 : 1); i <= regex.numMem; i++) {
+ repeatStk[i + memStartStk] = repeatStk[i + memEndStk] = INVALID_INDEX;
+ }
+ }
+ }
+
private static StackEntry[] allocateStack() {
StackEntry[]stack = new StackEntry[Config.INIT_MATCH_STACK_SIZE];
stack[0] = new StackEntry();
@@ -88,23 +94,14 @@ abstract class StackMachine extends Matcher implements StackType {
return stack;
}
- protected final void init() {
- if (stack != null) pushEnsured(ALT, regex.codeLength - 1); /* bottom stack */
- if (repeatStk != null) {
- for (int i = (Config.USE_SUBEXP_CALL ? 0 : 1); i <= regex.numMem; i++) {
- repeatStk[i + memStartStk] = repeatStk[i + memEndStk] = INVALID_INDEX;
- }
- }
- }
-
- protected final StackEntry ensure1() {
+ private final StackEntry ensure1() {
if (stk >= stack.length) doubleStack();
StackEntry e = stack[stk];
if (e == null) stack[stk] = e = new StackEntry();
return e;
}
- protected final void pushType(int type) {
+ private final void pushType(int type) {
ensure1().type = type;
stk++;
}
@@ -174,7 +171,7 @@ abstract class StackMachine extends Matcher implements StackType {
stk++;
}
- protected final void pushEnsured(int type, int pat) {
+ private final void pushEnsured(int type, int pat) {
StackEntry e = stack[stk];
e.type = type;
e.setStatePCode(pat);
@@ -328,9 +325,6 @@ abstract class StackMachine extends Matcher implements StackType {
stk++;
}
- // stack debug routines here
- // ...
-
protected final void popOne() {
stk--;
}
@@ -383,8 +377,6 @@ abstract class StackMachine extends Matcher implements StackType {
repeatStk[memStartStk + e.getMemNum()] = e.getMemStart();
repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd();
} else if (e.type == REPEAT_INC) {
- //int si = stack[stk + IREPEAT_INC_SI];
- //stack[si + IREPEAT_COUNT]--;
stack[e.getSi()].decreaseRepeatCount();
} else if (e.type == MEM_END) {
repeatStk[memStartStk + e.getMemNum()] = e.getMemStart();
@@ -406,8 +398,6 @@ abstract class StackMachine extends Matcher implements StackType {
repeatStk[memStartStk + e.getMemNum()] = e.getMemStart();
repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd();
} else if (e.type == REPEAT_INC) {
- //int si = stack[stk + IREPEAT_INC_SI];
- //stack[si + IREPEAT_COUNT]--;
stack[e.getSi()].decreaseRepeatCount();
} else if (e.type == MEM_END){
repeatStk[memStartStk + e.getMemNum()] = e.getMemStart();
@@ -429,8 +419,6 @@ abstract class StackMachine extends Matcher implements StackType {
repeatStk[memStartStk + e.getMemNum()] = e.getMemStart();
repeatStk[memEndStk + e.getMemNum()] = e.getMemEnd();
} else if (e.type == REPEAT_INC) {
- //int si = stack[stk + IREPEAT_INC_SI];
- //stack[si + IREPEAT_COUNT]--;
stack[e.getSi()].decreaseRepeatCount();
} else if (e.type == MEM_END) {
repeatStk[memStartStk + e.getMemNum()] = e.getMemStart();
--
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