Code cleanup.

This commit is contained in:
2023-01-21 20:14:41 +08:00
parent c1c354959d
commit 9f73c8ffad
2 changed files with 4 additions and 4 deletions

View File

@@ -137,7 +137,7 @@ namespace Cryville.Crtr.Event {
AddChild(child.Key, cc, r);
}
var pms = new Dictionary<StampedEvent, RealtimeMotionValue>(PlayingMotions.Count);
var pms = new Dictionary<StampedEvent, RealtimeMotionValue>(Math.Max(4, PlayingMotions.Count));
foreach (var m in PlayingMotions)
pms.Add(m.Key, m.Value);
r.PlayingMotions = pms;

View File

@@ -24,10 +24,9 @@ namespace Cryville.Crtr.Event {
= new SimpleObjectPool<Dictionary<RealtimeMotionValue, Identifier>>(1024);
Dictionary<RealtimeMotionValue, Identifier> _rented;
public RealtimeMotionValue Rent(Identifier name) {
var n = name;
var obj = _buckets[n].Rent();
var obj = _buckets[name].Rent();
if (_rented == null) _rented = _dictPool.Rent();
_rented.Add(obj, n);
_rented.Add(obj, name);
return obj;
}
public void Return(RealtimeMotionValue obj) {
@@ -35,6 +34,7 @@ namespace Cryville.Crtr.Event {
_rented.Remove(obj);
}
public void ReturnAll() {
if (_rented == null) return;
foreach (var obj in _rented)
_buckets[obj.Value].Return(obj.Key);
_rented.Clear();