[jruby-joni] 11/279: Allocate stack frames lazily since more likely weak referenced stack will go away.
Hideki Yamane
henrich at moszumanska.debian.org
Mon Nov 16 11:26:28 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 d96734a109659b2118ba81fa6dc03eb756d29acb
Author: Marcin Mielżyński <lopx at gazeta.pl>
Date: Sat Jan 12 19:05:07 2008 +0000
Allocate stack frames lazily since more likely weak referenced stack will go away.
git-svn-id: http://svn.codehaus.org/jruby/joni/trunk@5556 961051c9-f516-0410-bf72-c9f7e237a7b7
---
src/org/joni/StackMachine.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/org/joni/StackMachine.java b/src/org/joni/StackMachine.java
index 7a3076f..a1c4b72 100644
--- a/src/org/joni/StackMachine.java
+++ b/src/org/joni/StackMachine.java
@@ -55,15 +55,14 @@ abstract class StackMachine extends IntHolder implements StackType {
}
private static StackEntry[] allocateStack() {
- StackEntry[] stack = new StackEntry[Config.INIT_MATCH_STACK_SIZE];
- for (int i=0; i<Config.INIT_MATCH_STACK_SIZE; i++) stack[i] = new StackEntry();
+ StackEntry[]stack = new StackEntry[Config.INIT_MATCH_STACK_SIZE];
+ stack[0] = new StackEntry();
return stack;
}
private void doubleStack() {
StackEntry[] newStack = new StackEntry[stack.length << 1];
System.arraycopy(stack, 0, newStack, 0, stack.length);
- for (int i=stack.length; i<newStack.length; i++) newStack[i] = new StackEntry();
stack = newStack;
}
@@ -79,7 +78,7 @@ abstract class StackMachine extends IntHolder implements StackType {
WeakReference<StackEntry[]> ref = stacks.get();
StackEntry[] stack = ref.get();
if (stack == null) {
- ref = new WeakReference<StackEntry[]>(stack = allocateStack());
+ ref = new WeakReference<StackEntry[]>(stack = allocateStack());
stacks.set(ref);
}
return stack;
@@ -96,6 +95,7 @@ abstract class StackMachine extends IntHolder implements StackType {
protected final void ensure1() {
if (stk >= stack.length) doubleStack();
+ if (stack[stk] == null) stack[stk] = new StackEntry();
}
protected final void pushType(int type) {
--
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