public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
commit accb5763547fc74b60c0942354f97a72a6eb9bd3
Author: Ben Browning <bbrownin@redhat.com>
Date: Mon May 14 10:17:10 2012 -0400
 
Ruby's recursiveKey is read-only, doesn't need to be ThreadLocal (Fixes #162)
 
Modified src/org/jruby/Ruby.java
diff --git a/src/org/jruby/Ruby.java b/src/org/jruby/Ruby.java
index feb66ce..5912532 100644
--- a/src/org/jruby/Ruby.java
+++ b/src/org/jruby/Ruby.java
@@ -2885,11 +2885,6 @@ public final class Ruby {
// clear out threadlocals so they don't leak
recursive = new ThreadLocal<Map<String, RubyHash>>();
- recursiveKey = new ThreadLocal<RubySymbol>() {
- protected RubySymbol initialValue() {
- return newSymbol("__recursive_key__");
- }
- };
while (!atExitBlocks.empty()) {
RubyProc proc = atExitBlocks.pop();
@@ -3806,7 +3801,7 @@ public final class Ruby {
ExecRecursiveParams p = new ExecRecursiveParams();
p.list = recursiveListAccess();
p.objid = obj.id();
- boolean outermost = outer && !recursiveCheck(p.list, recursiveKey.get(), null);
+ boolean outermost = outer && !recursiveCheck(p.list, recursiveKey, null);
if(recursiveCheck(p.list, p.objid, pairid)) {
if(outer && !outermost) {
throw new RecursiveError(p.list);
@@ -3819,7 +3814,7 @@ public final class Ruby {
p.pairid = pairid;
if(outermost) {
- recursivePush(p.list, recursiveKey.get(), null);
+ recursivePush(p.list, recursiveKey, null);
try {
result = execRecursiveI(p);
} catch(RecursiveError e) {
@@ -3829,7 +3824,7 @@ public final class Ruby {
result = p.list;
}
}
- recursivePop(p.list, recursiveKey.get(), null);
+ recursivePop(p.list, recursiveKey, null);
if(result == p.list) {
result = func.call(obj, true);
}
@@ -4457,11 +4452,7 @@ public final class Ruby {
// structures and such for recursive operations
private ThreadLocal<Map<String, RubyHash>> recursive = new ThreadLocal<Map<String, RubyHash>>();
- private ThreadLocal<RubySymbol> recursiveKey = new ThreadLocal<RubySymbol>() {
- protected RubySymbol initialValue() {
- return newSymbol("__recursive_key__");
- }
- };
+ private RubySymbol recursiveKey = newSymbol("__recursive_key__");
private ThreadLocal<Boolean> inRecursiveListOperation = new ThreadLocal<Boolean>();
private FFI ffi;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.