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:
5d4a61f
)
2002/08/18 05:28:23
author
megacz
<megacz@xwt.org>
Fri, 30 Jan 2004 06:50:11 +0000
(06:50 +0000)
committer
megacz
<megacz@xwt.org>
Fri, 30 Jan 2004 06:50:11 +0000
(06:50 +0000)
darcs-hash:
20040130065011
-2ba56-
eadde0f2dbb9db558c3f6cbdfe22de95be3cbcd8
.gz
CHANGES
patch
|
blob
|
history
src/org/xwt/Trap.java
patch
|
blob
|
history
diff --git
a/CHANGES
b/CHANGES
index
5951acb
..
b507a49
100644
(file)
--- a/
CHANGES
+++ b/
CHANGES
@@
-378,4
+378,6
@@
17-Aug megacz Vec.java: fixed infinite loop
17-Aug megacz Vec.java: fixed infinite loop
+17-Aug megacz Trap.java: switched allTraps from a Vector to a Hashtable
+
diff --git
a/src/org/xwt/Trap.java
b/src/org/xwt/Trap.java
index
d2b3954
..
94624ae
100644
(file)
--- a/
src/org/xwt/Trap.java
+++ b/
src/org/xwt/Trap.java
@@
-16,7
+16,7
@@
public class Trap {
// Static Data //////////////////////////////////////////////////////////////
/** a vector of weak references to all instances of Trap; used for retheming */
// Static Data //////////////////////////////////////////////////////////////
/** a vector of weak references to all instances of Trap; used for retheming */
- private static Vec allTraps = new Vec(1000);
+ private static Hashtable allTraps = new Hashtable(1000);
/** List of properties that cannot be trapped */
private static final Hash PROHIBITED = new Hash(120, 3);
/** List of properties that cannot be trapped */
private static final Hash PROHIBITED = new Hash(120, 3);
@@
-32,6
+32,9
@@
public class Trap {
for(int i=0; i<p.length; i++) PROHIBITED.put(p[i], Boolean.TRUE);
};
for(int i=0; i<p.length; i++) PROHIBITED.put(p[i], Boolean.TRUE);
};
+ private static Object dummy = new Object();
+
+
// Instance Members ////////////////////////////////////////////////////////
/** the box on which this trap was placed */
// Instance Members ////////////////////////////////////////////////////////
/** the box on which this trap was placed */
@@
-55,8
+58,9
@@
public class Trap {
/** The nodeName of the Template whose script placed the trap. See Template.nodeName for more detail. */
private String placerNodeName = null;
/** The nodeName of the Template whose script placed the trap. See Template.nodeName for more detail. */
private String placerNodeName = null;
- /** the index of this Trap in the allTraps vector */
- private int indexInAllTraps = 0;
+ /** our weak reference in the allTraps Hash */
+ private Weak myWeak = Platform.getWeak(this);
+
// Static Methods //////////////////////////////////////////////////////////////////////////
// Static Methods //////////////////////////////////////////////////////////////////////////
@@
-146,25
+150,27
@@
public class Trap {
/** removes all traps whose function's ultimate parent scope is <tt>b</tt>. Used for retheming */
public static void removeAllTrapsByBox(Box b) {
/** removes all traps whose function's ultimate parent scope is <tt>b</tt>. Used for retheming */
public static void removeAllTrapsByBox(Box b) {
- for(int i=0; i<allTraps.size(); i++) {
- Trap t = (Trap)((Weak)allTraps.elementAt(i)).get();
- if (t == null) continue;
+ Enumeration e = allTraps.keys();
+ while(e.hasMoreElements()) {
+ Weak w = (Weak)e.nextElement();
+ Trap t = (Trap)w.get();
+ if (t == null) {
+ allTraps.remove(w);
+ continue;
+ }
for(Scriptable cur = t.f; cur != null; cur = cur.getParentScope()) {
if (cur == b) {
t.delete();
for(Scriptable cur = t.f; cur != null; cur = cur.getParentScope()) {
if (cur == b) {
t.delete();
- i--;
break;
}
}
}
}
break;
}
}
}
}
+
// Instance Methods //////////////////////////////////////////////////////////////////////////
// Instance Methods //////////////////////////////////////////////////////////////////////////
- private Trap() {
- indexInAllTraps = allTraps.size();
- allTraps.addElement(Platform.getWeak(this));
- }
+ private Trap() { allTraps.put(myWeak, dummy); }
/** perform this trap -- arg.length == 0 if this is a get; otherwise it contains a single element to be put */
public Object perform(Object[] arg) {
/** perform this trap -- arg.length == 0 if this is a get; otherwise it contains a single element to be put */
public Object perform(Object[] arg) {
@@
-220,11
+226,7
@@
public class Trap {
}
if (trapee.surface != null && !trapee.is_trapped("KeyPressed") && !trapee.is_trapped("KeyReleased"))
trapee.surface.keywatchers.removeElement(trapee);
}
if (trapee.surface != null && !trapee.is_trapped("KeyPressed") && !trapee.is_trapped("KeyReleased"))
trapee.surface.keywatchers.removeElement(trapee);
- if (allTraps.size() == 1) allTraps.setSize(0);
- else {
- allTraps.setElementAt(allTraps.elementAt(allTraps.size() - 1), indexInAllTraps);
- allTraps.setSize(allTraps.size() - 1);
- }
+ allTraps.remove(myWeak);
}
/** per-thread storage for Traps */
}
/** per-thread storage for Traps */
@@
-250,3
+252,4
@@
public class Trap {
}
}
}
}
+