Introduce IntKeyedDictionary
to improve performance.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Buffers;
|
||||
using Cryville.Common.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr.Event {
|
||||
internal class RMVPool : CategorizedPool<Identifier, RealtimeMotionValue> {
|
||||
internal class RMVPool : CategorizedPool<int, RealtimeMotionValue> {
|
||||
private class Bucket : ObjectPool<RealtimeMotionValue> {
|
||||
readonly MotionRegistry _reg;
|
||||
public Bucket(Identifier name, int capacity) : base(capacity) {
|
||||
@@ -13,12 +14,12 @@ namespace Cryville.Crtr.Event {
|
||||
return new RealtimeMotionValue().Init(_reg.InitValue);
|
||||
}
|
||||
}
|
||||
readonly Dictionary<Identifier, ObjectPool<RealtimeMotionValue>> m_buckets;
|
||||
protected override IReadOnlyDictionary<Identifier, ObjectPool<RealtimeMotionValue>> Buckets { get { return m_buckets; } }
|
||||
readonly IntKeyedDictionary<ObjectPool<RealtimeMotionValue>> m_buckets;
|
||||
protected override IReadOnlyDictionary<int, ObjectPool<RealtimeMotionValue>> Buckets { get { return m_buckets; } }
|
||||
public RMVPool() {
|
||||
m_buckets = new Dictionary<Identifier, ObjectPool<RealtimeMotionValue>>(ChartPlayer.motionRegistry.Count);
|
||||
m_buckets = new IntKeyedDictionary<ObjectPool<RealtimeMotionValue>>(ChartPlayer.motionRegistry.Count);
|
||||
foreach (var reg in ChartPlayer.motionRegistry)
|
||||
m_buckets.Add(reg.Key, new Bucket(reg.Key, 4096));
|
||||
m_buckets.Add(reg.Key.Key, new Bucket(reg.Key, 4096));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user