Introduce IntKeyedDictionary
to improve performance.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Buffers;
|
||||
using Cryville.Common.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr.Event {
|
||||
@@ -11,7 +12,7 @@ namespace Cryville.Crtr.Event {
|
||||
Value.CopyTo(dest.Value);
|
||||
}
|
||||
}
|
||||
internal class MotionCachePool : CategorizedPool<Identifier, MotionCache> {
|
||||
internal class MotionCachePool : CategorizedPool<int, MotionCache> {
|
||||
private class Bucket : ObjectPool<MotionCache> {
|
||||
readonly MotionRegistry _reg;
|
||||
public Bucket(Identifier name, int capacity) : base(capacity) {
|
||||
@@ -26,12 +27,12 @@ namespace Cryville.Crtr.Event {
|
||||
obj.Valid = false;
|
||||
}
|
||||
}
|
||||
readonly Dictionary<Identifier, ObjectPool<MotionCache>> m_buckets;
|
||||
protected override IReadOnlyDictionary<Identifier, ObjectPool<MotionCache>> Buckets { get { return m_buckets; } }
|
||||
readonly IntKeyedDictionary<ObjectPool<MotionCache>> m_buckets;
|
||||
protected override IReadOnlyDictionary<int, ObjectPool<MotionCache>> Buckets { get { return m_buckets; } }
|
||||
public MotionCachePool() {
|
||||
m_buckets = new Dictionary<Identifier, ObjectPool<MotionCache>>(ChartPlayer.motionRegistry.Count);
|
||||
m_buckets = new IntKeyedDictionary<ObjectPool<MotionCache>>(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