[jruby-joni] 49/279: Reduce array lookups.
Hideki Yamane
henrich at moszumanska.debian.org
Mon Nov 16 11:26:41 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 075afccee2923f595acadc754210166aba025c7a
Author: Marcin Mielżyński <lopx at gazeta.pl>
Date: Wed Jan 7 22:24:18 2009 +0000
Reduce array lookups.
git-svn-id: http://svn.codehaus.org/jruby/joni/trunk@8639 961051c9-f516-0410-bf72-c9f7e237a7b7
---
src/org/joni/ByteCodeMachine.java | 4 +-
src/org/joni/StackMachine.java | 77 ++++++++++-----------------------------
2 files changed, 21 insertions(+), 60 deletions(-)
diff --git a/src/org/joni/ByteCodeMachine.java b/src/org/joni/ByteCodeMachine.java
index 23abe04..bcaea73 100644
--- a/src/org/joni/ByteCodeMachine.java
+++ b/src/org/joni/ByteCodeMachine.java
@@ -1483,7 +1483,7 @@ class ByteCodeMachine extends StackMachine {
int mem = code[ip++]; /* mem: OP_REPEAT ID */
int addr= code[ip++];
- ensure1();
+ // ensure1();
repeatStk[mem] = stk;
pushRepeat(mem, ip);
@@ -1496,7 +1496,7 @@ class ByteCodeMachine extends StackMachine {
int mem = code[ip++]; /* mem: OP_REPEAT ID */
int addr= code[ip++];
- ensure1();
+ // ensure1();
repeatStk[mem] = stk;
pushRepeat(mem, ip);
diff --git a/src/org/joni/StackMachine.java b/src/org/joni/StackMachine.java
index c999130..7fe60a7 100644
--- a/src/org/joni/StackMachine.java
+++ b/src/org/joni/StackMachine.java
@@ -91,15 +91,17 @@ abstract class StackMachine extends Matcher implements StackType {
}
}
}
-
- protected final void ensure1() {
+
+ protected final StackEntry ensure1() {
if (stk >= stack.length) doubleStack();
- if (stack[stk] == null) stack[stk] = new StackEntry();
+ StackEntry e = stack[stk];
+ if (e == null) stack[stk] = e = new StackEntry();
+ return e;
}
protected final void pushType(int type) {
- ensure1();
- stack[stk++].type = type;
+ ensure1().type = type;
+ stk++;
}
// CEC
@@ -157,51 +159,39 @@ abstract class StackMachine extends Matcher implements StackType {
}
private void push(int type, int pat, int s, int prev) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = type;
e.setStatePCode(pat);
e.setStatePStr(s);
e.setStatePStrPrev(prev);
-
if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(0);
-
stk++;
}
protected final void pushEnsured(int type, int pat) {
StackEntry e = stack[stk];
-
e.type = type;
e.setStatePCode(pat);
if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(0);
-
stk++;
}
protected final void pushAltWithStateCheck(int pat, int s, int sprev, int snum) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = ALT;
e.setStatePCode(pat);
e.setStatePStr(s);
e.setStatePStrPrev(sprev);
if (Config.USE_COMBINATION_EXPLOSION_CHECK) e.setStateCheck(stateCheckBuff != null ? snum : 0);
-
stk++;
}
protected final void pushStateCheck(int s, int snum) {
if (stateCheckBuff != null) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = STATE_CHECK_MARK;
e.setStatePStr(s);
e.setStateCheck(snum);
-
stk++;
}
}
@@ -227,65 +217,48 @@ abstract class StackMachine extends Matcher implements StackType {
}
protected final void pushRepeat(int id, int pat) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = REPEAT;
e.setRepeatNum(id);
e.setRepeatPCode(pat);
e.setRepeatCount(0);
-
stk++;
}
protected final void pushRepeatInc(int sindex) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = REPEAT_INC;
e.setSi(sindex);
-
stk++;
}
protected final void pushMemStart(int mnum, int s) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = MEM_START;
e.setMemNum(mnum);
e.setMemPstr(s);
e.setMemStart(repeatStk[memStartStk + mnum]);
e.setMemEnd(repeatStk[memEndStk + mnum]);
-
repeatStk[memStartStk + mnum] = stk;
repeatStk[memEndStk + mnum] = INVALID_INDEX;
-
stk++;
}
protected final void pushMemEnd(int mnum, int s) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = MEM_END;
e.setMemNum(mnum);
e.setMemPstr(s);
e.setMemStart(repeatStk[memStartStk + mnum]);
e.setMemEnd(repeatStk[memEndStk + mnum]);
-
repeatStk[memEndStk + mnum] = stk;
-
stk++;
}
protected final void pushMemEndMark(int mnum) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = MEM_END_MARK;
e.setMemNum(mnum);
-
stk++;
}
@@ -307,42 +280,30 @@ abstract class StackMachine extends Matcher implements StackType {
}
protected final void pushNullCheckStart(int cnum, int s) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = NULL_CHECK_START;
e.setNullCheckNum(cnum);
e.setNullCheckPStr(s);
-
stk++;
}
protected final void pushNullCheckEnd(int cnum) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = NULL_CHECK_END;
e.setNullCheckNum(cnum);
-
stk++;
}
protected final void pushCallFrame(int pat) {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = CALL_FRAME;
e.setCallFrameRetAddr(pat);
-
stk++;
}
protected final void pushReturn() {
- ensure1();
- StackEntry e = stack[stk];
-
+ StackEntry e = ensure1();
e.type = RETURN;
-
stk++;
}
--
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