Introduce IdentifierManager to improve PDT evaluator performance.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
@@ -36,14 +37,14 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
public class Enum<T> : PropOp {
|
||||
readonly static Dictionary<string, int> _cache = new Dictionary<string, int>();
|
||||
readonly static Dictionary<int, int> _cache = new Dictionary<int, int>();
|
||||
readonly Action<T> _cb;
|
||||
public Enum(Action<T> cb) {
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new ArgumentException("Type is not enum");
|
||||
var names = typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
_cache[names[i].Name] = Convert.ToInt32(names[i].GetValue(null));
|
||||
_cache[IdentifierManager.SharedInstance.Request(names[i].Name)] = Convert.ToInt32(names[i].GetValue(null));
|
||||
_cb = cb;
|
||||
}
|
||||
protected override void Execute() {
|
||||
|
Reference in New Issue
Block a user