diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-06 16:06:02 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-06 16:06:02 -0800 |
| commit | ce3b04603d7af995004291d9a7eb668f313e6772 (patch) | |
| tree | 45d3b45026c54e0a35aa3bd37069c7cccb0729bf /chapter27/src/main | |
| parent | 8f460340cfe01a4945635251bcd33b257b699bf7 (diff) | |
| download | Simple-ce3b04603d7af995004291d9a7eb668f313e6772.tar.gz Simple-ce3b04603d7af995004291d9a7eb668f313e6772.zip | |
Cleanup public escapes
Drop "frozen" public escapes, and recompute in Start/Stop so Opto gets a precise escape set.
Rename XInt.free -> XInt.alloc
Fix some String tests to not escape by default
Diffstat (limited to 'chapter27/src/main')
| -rw-r--r-- | chapter27/src/main/java/com/seaofnodes/simple/type/XInt.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/chapter27/src/main/java/com/seaofnodes/simple/type/XInt.java b/chapter27/src/main/java/com/seaofnodes/simple/type/XInt.java index 17fc4bd3..a69783be 100644 --- a/chapter27/src/main/java/com/seaofnodes/simple/type/XInt.java +++ b/chapter27/src/main/java/com/seaofnodes/simple/type/XInt.java @@ -92,7 +92,7 @@ public abstract class XInt { int len = Math.max(xs.length,idx+1); if( (x&31)==31 && idx+1==len ) len++; - int[] ys = free(len); + int[] ys = alloc(len); System.arraycopy(xs,1,ys,1,xs.length-1); ys[idx] |= mask(x); return intern(ys); @@ -112,7 +112,7 @@ public abstract class XInt { len--; // Replace with trimmed if( len < xs.length ) { - var ys = free(len); + var ys = alloc(len); System.arraycopy(xs,1,ys,1,len-1); xs = _free(xs,ys); } @@ -146,8 +146,9 @@ public abstract class XInt { FREES.setX(len, xss = new Ary<>(int[].class)); return xss; } - // Pull free array from free list - static int[] free(int len) { + // Allocate a zeroed mutable array, reusing the free list. + // Pass it to intern after filling; do not retain a mutable reference. + public static int[] alloc(int len) { int[] xs = _xss(len).pop(); if( xs==null ) { NEWS++; xs = new int[len]; } @@ -176,7 +177,7 @@ public abstract class XInt { if( isX ) return xs; if( isY ) return ys; // Get a free one - int[] ms = free(max); + int[] ms = alloc(max); for( int i=1; i<min; i++ ) ms[i] = xs[i] | ys[i]; for( int i=min; i<ms.length; i++ ) { @@ -189,7 +190,7 @@ public abstract class XInt { // Dual: flip all the bits public static int[] dual(int[] xs) { - int[] ds = free(xs.length); + int[] ds = alloc(xs.length); for( int i=1; i<xs.length; i++ ) ds[i] = ~xs[i]; return intern(ds); |
