More data-structure inlining
This commit is contained in:
parent
fd8b445482
commit
7d9174c363
|
@ -12,7 +12,9 @@ public class Turn {
|
||||||
private boolean _complete = false;
|
private boolean _complete = false;
|
||||||
|
|
||||||
private Actor _pendingTarget = null;
|
private Actor _pendingTarget = null;
|
||||||
private Consumer<Turn>[] _pendingQ = null;
|
private Consumer<Turn> _pending0 = null;
|
||||||
|
private Consumer<Turn> _pending1 = null;
|
||||||
|
private Consumer<Turn> _pending2 = null;
|
||||||
private Map<Actor, List<Consumer<Turn>>> _pending = null;
|
private Map<Actor, List<Consumer<Turn>>> _pending = null;
|
||||||
|
|
||||||
public static void forActor(Actor a, Consumer<Turn> f) {
|
public static void forActor(Actor a, Consumer<Turn> f) {
|
||||||
|
@ -47,11 +49,13 @@ public class Turn {
|
||||||
_pending = null;
|
_pending = null;
|
||||||
} else if (_pendingTarget != null) {
|
} else if (_pendingTarget != null) {
|
||||||
var ac = _pendingTarget;
|
var ac = _pendingTarget;
|
||||||
var q = _pendingQ;
|
Consumer<Turn> q0 = _pending0, q1 = _pending1, q2 = _pending2;
|
||||||
_pendingTarget = null;
|
_pendingTarget = null;
|
||||||
_pendingQ = null;
|
_pending0 = _pending1 = _pending2 = null;
|
||||||
ac.execute(() -> Turn.forActor(ac, t -> {
|
ac.execute(() -> Turn.forActor(ac, t -> {
|
||||||
for (var f : q) if (f != null) f.accept(t);
|
q0.accept(t);
|
||||||
|
if (q1 != null) q1.accept(t);
|
||||||
|
if (q2 != null) q2.accept(t);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
_complete = true;
|
_complete = true;
|
||||||
|
@ -64,22 +68,21 @@ public class Turn {
|
||||||
_pendingTarget = target;
|
_pendingTarget = target;
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
var q = (Consumer<Turn>[]) new Consumer<?>[3];
|
var q = (Consumer<Turn>[]) new Consumer<?>[3];
|
||||||
_pendingQ = q;
|
_pending0 = action;
|
||||||
_pendingQ[0] = action;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_pendingTarget == target) {
|
if (_pendingTarget == target) {
|
||||||
if (_pendingQ[1] == null) { _pendingQ[1] = action; return; }
|
if (_pending1 == null) { _pending1 = action; return; }
|
||||||
if (_pendingQ[2] == null) { _pendingQ[2] = action; return; }
|
if (_pending2 == null) { _pending2 = action; return; }
|
||||||
}
|
}
|
||||||
_pending = new HashMap<>();
|
_pending = new HashMap<>();
|
||||||
var q = new LinkedList<Consumer<Turn>>();
|
var q = new LinkedList<Consumer<Turn>>();
|
||||||
_pending.put(_pendingTarget, q);
|
_pending.put(_pendingTarget, q);
|
||||||
q.add(_pendingQ[0]);
|
q.add(_pending0);
|
||||||
if (_pendingQ[1] != null) q.add(_pendingQ[1]);
|
if (_pending1 != null) q.add(_pending1);
|
||||||
if (_pendingQ[2] != null) q.add(_pendingQ[2]);
|
if (_pending2 != null) q.add(_pending2);
|
||||||
_pendingTarget = null;
|
_pendingTarget = null;
|
||||||
_pendingQ = null;
|
_pending0 = _pending1 = _pending2 = null;
|
||||||
}
|
}
|
||||||
_pending.computeIfAbsent(target, k -> new LinkedList<>()).add(action);
|
_pending.computeIfAbsent(target, k -> new LinkedList<>()).add(action);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue