Optimize GC for input proxy.
This commit is contained in:
@@ -17,6 +17,7 @@ namespace Cryville.Crtr {
|
||||
*(int*)(ptr + 3 * sizeof(float)) = PdtInternalType.Number;
|
||||
}
|
||||
}
|
||||
_vecsrc = new PropSrc.Arbitrary(PdtInternalType.Vector, _vecbuf);
|
||||
_etor = ChartPlayer.etor;
|
||||
_ruleset = ruleset;
|
||||
_judge = judge;
|
||||
@@ -168,11 +169,12 @@ namespace Cryville.Crtr {
|
||||
static readonly int _var_value = IdentifierManager.SharedInstance.Request("value");
|
||||
static readonly PropOp.Arbitrary _arbop = new PropOp.Arbitrary();
|
||||
readonly byte[] _vecbuf = new byte[3 * sizeof(float) + sizeof(int)];
|
||||
readonly PropSrc.Arbitrary _vecsrc;
|
||||
readonly Dictionary<InputHandler, double> _timeOrigins = new Dictionary<InputHandler, double>();
|
||||
readonly Dictionary<InputSource, int> _activeCounts = new Dictionary<InputSource, int>();
|
||||
readonly Dictionary<InputIdentifier, float> _vect = new Dictionary<InputIdentifier, float>();
|
||||
readonly Dictionary<ProxiedInputIdentifier, PropSrc.Arbitrary> _vecs = new Dictionary<ProxiedInputIdentifier, PropSrc.Arbitrary>();
|
||||
static readonly byte[] _nullvalue = new byte[0];
|
||||
static readonly PropSrc.Arbitrary _nullsrc = new PropSrc.Arbitrary(PdtInternalType.Null, new byte[0]);
|
||||
unsafe void OnInput(InputIdentifier id, InputVector vec) {
|
||||
lock (_lock) {
|
||||
InputProxyEntry proxy;
|
||||
@@ -181,14 +183,15 @@ namespace Cryville.Crtr {
|
||||
float ft, tt = (float)(vec.Time - _timeOrigins[id.Source.Handler]);
|
||||
if (!_vect.TryGetValue(id, out ft)) ft = tt;
|
||||
if (vec.IsNull) {
|
||||
_etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Null, _nullvalue));
|
||||
_etor.ContextCascadeUpdate(_var_value, _nullsrc);
|
||||
OnInput(id, proxy.Target, ft, tt, true);
|
||||
}
|
||||
else {
|
||||
fixed (byte* ptr = _vecbuf) {
|
||||
*(Vector3*)ptr = vec.Vector;
|
||||
}
|
||||
_etor.ContextCascadeUpdate(_var_value, new PropSrc.Arbitrary(PdtInternalType.Vector, _vecbuf));
|
||||
_vecsrc.Invalidate();
|
||||
_etor.ContextCascadeUpdate(_var_value, _vecsrc);
|
||||
OnInput(id, proxy.Target, ft, tt, false);
|
||||
}
|
||||
_vect[id] = tt;
|
||||
@@ -212,7 +215,7 @@ namespace Cryville.Crtr {
|
||||
else {
|
||||
var pid = new ProxiedInputIdentifier { Source = id, Target = target };
|
||||
PropSrc.Arbitrary fv, tv = _etor.ContextCascadeLookup(_var_value);
|
||||
if (!_vecs.TryGetValue(pid, out fv)) fv = new PropSrc.Arbitrary(PdtInternalType.Null, _nullvalue);
|
||||
if (!_vecs.TryGetValue(pid, out fv)) fv = _nullsrc;
|
||||
if (fv.Type != PdtInternalType.Null || tv.Type != PdtInternalType.Null) {
|
||||
if (fv.Type == PdtInternalType.Null) _activeCounts[id.Source]++;
|
||||
_etor.ContextCascadeInsert();
|
||||
|
Reference in New Issue
Block a user