Optimize GC for motions.

This commit is contained in:
2023-02-07 23:15:52 +08:00
parent 4e9d7e5b87
commit 187f07d2c9
4 changed files with 11 additions and 12 deletions

View File

@@ -116,11 +116,6 @@ namespace Cryville.Crtr.Event {
r.Values = mvs;
var cvs = new Dictionary<Identifier, MotionCache>(ChartPlayer.motionRegistry.Count);
foreach (var cv in CachedValues) {
var dv = r.MCPool.Rent(cv.Key);
cv.Value.CopyTo(dv);
cvs.Add(cv.Key, dv);
}
r.CachedValues = cvs;
r.Children = new Dictionary<EventContainer, ContainerState>();
@@ -190,10 +185,12 @@ namespace Cryville.Crtr.Event {
if (Disposed) return;
Disposed = true;
if (CloneType == 1) Handler.Dispose();
if (CloneType == 1 || CloneType == 17) {
RMVPool.ReturnAll();
MCPool.ReturnAll();
}
foreach (var s in Children)
s.Value.Dispose();
RMVPool.ReturnAll();
MCPool.ReturnAll();
}
public void DisposeAll() {
foreach (var s in Children)

View File

@@ -50,6 +50,7 @@ namespace Cryville.Crtr.Event {
_buckets[obj.Value].Return(obj.Key);
_rented.Clear();
_dictPool.Return(_rented);
_rented = null;
}
}
}

View File

@@ -39,6 +39,7 @@ namespace Cryville.Crtr.Event {
_buckets[obj.Value].Return(obj.Key);
_rented.Clear();
_dictPool.Return(_rented);
_rented = null;
}
}
}

View File

@@ -911,11 +911,11 @@ namespace Cryville.Crtr {
}
public override bool IsZero() {
if (!xw.Equals(0)) return false;
if (!xh.Equals(0)) return false;
if (!yw.Equals(0)) return false;
if (!yh.Equals(0)) return false;
if (!z.Equals(0)) return false;
if (xw == null || xw != 0) return false;
if (xh == null || xh != 0) return false;
if (yw == null || yw != 0) return false;
if (xh == null || xh != 0) return false;
if (z == null || z != 0) return false;
return true;
}