From 9f73c8ffad3ea18eda813631756c8fea4d13592c Mon Sep 17 00:00:00 2001 From: PopSlime Date: Sat, 21 Jan 2023 20:14:41 +0800 Subject: [PATCH] Code cleanup. --- Assets/Cryville/Crtr/Event/ContainerState.cs | 2 +- Assets/Cryville/Crtr/Event/RMVPool.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Cryville/Crtr/Event/ContainerState.cs b/Assets/Cryville/Crtr/Event/ContainerState.cs index 55e56dc..ff96a17 100644 --- a/Assets/Cryville/Crtr/Event/ContainerState.cs +++ b/Assets/Cryville/Crtr/Event/ContainerState.cs @@ -137,7 +137,7 @@ namespace Cryville.Crtr.Event { AddChild(child.Key, cc, r); } - var pms = new Dictionary(PlayingMotions.Count); + var pms = new Dictionary(Math.Max(4, PlayingMotions.Count)); foreach (var m in PlayingMotions) pms.Add(m.Key, m.Value); r.PlayingMotions = pms; diff --git a/Assets/Cryville/Crtr/Event/RMVPool.cs b/Assets/Cryville/Crtr/Event/RMVPool.cs index a6ab375..4cbff27 100644 --- a/Assets/Cryville/Crtr/Event/RMVPool.cs +++ b/Assets/Cryville/Crtr/Event/RMVPool.cs @@ -24,10 +24,9 @@ namespace Cryville.Crtr.Event { = new SimpleObjectPool>(1024); Dictionary _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();