projects
/
org.ibex.core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b3d9c10
)
2003/11/29 06:22:33
author
megacz
<megacz@xwt.org>
Fri, 30 Jan 2004 07:42:24 +0000
(07:42 +0000)
committer
megacz
<megacz@xwt.org>
Fri, 30 Jan 2004 07:42:24 +0000
(07:42 +0000)
darcs-hash:
20040130074224
-2ba56-
4996212335d2f2a184719f861e1834201c13beb8
.gz
src/org/xwt/js/JS.java
patch
|
blob
|
history
diff --git
a/src/org/xwt/js/JS.java
b/src/org/xwt/js/JS.java
index
5da9e76
..
d187ecb
100644
(file)
--- a/
src/org/xwt/js/JS.java
+++ b/
src/org/xwt/js/JS.java
@@
-124,12
+124,16
@@
public class JS extends org.xwt.util.BalancedTree {
private static final Integer[] largeIntCache = new Integer[65535 / 4];
public static final Number N(int i) {
Integer ret = null;
private static final Integer[] largeIntCache = new Integer[65535 / 4];
public static final Number N(int i) {
Integer ret = null;
- if (i < smallIntCache.length) { ret = smallIntCache[i]; if (ret != null) return ret; }
- else ret = largeIntCache[i % largeIntCache.length];
+ int idx = i + smallIntCache.length / 2;
+ if (idx < smallIntCache.length && idx > 0) {
+ ret = smallIntCache[idx];
+ if (ret != null) return ret;
+ }
+ else ret = largeIntCache[Math.abs(idx % largeIntCache.length)];
if (ret == null || ret.intValue() != i) {
ret = new Integer(i);
if (ret == null || ret.intValue() != i) {
ret = new Integer(i);
- if (i < smallIntCache.length) smallIntCache[i] = ret;
- else largeIntCache[i % largeIntCache.length] = ret;
+ if (idx < smallIntCache.length && idx > 0) smallIntCache[idx] = ret;
+ else largeIntCache[Math.abs(idx % largeIntCache.length)] = ret;
}
return ret;
}
}
return ret;
}