Introduce IntKeyedDictionary to improve performance.

This commit is contained in:
2023-03-24 17:06:47 +08:00
parent 89f391f040
commit e2c683567e
18 changed files with 1274 additions and 94 deletions

View File

@@ -1,4 +1,5 @@
using Cryville.Common;
using Cryville.Common.Collections.Specialized;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -142,19 +143,19 @@ namespace Cryville.Crtr {
}
[JsonIgnore]
public Dictionary<int, PropSrc> PropSrcs { get; private set; }
public IntKeyedDictionary<PropSrc> PropSrcs { get; private set; }
protected void SubmitPropSrc(string name, PropSrc property) {
PropSrcs.Add(IdentifierManager.SharedInstance.Request(name), property);
}
[JsonIgnore]
public Dictionary<int, PropOp> PropOps { get; private set; }
public IntKeyedDictionary<PropOp> PropOps { get; private set; }
protected void SubmitPropOp(string name, PropOp property) {
PropOps.Add(IdentifierManager.SharedInstance.Request(name), property);
}
protected ChartEvent() {
PropSrcs = new Dictionary<int, PropSrc>();
PropOps = new Dictionary<int, PropOp>();
PropSrcs = new IntKeyedDictionary<PropSrc>();
PropOps = new IntKeyedDictionary<PropOp>();
SubmitPropSrc("event", new PropSrc.Float(() => {
int hash = GetHashCode();
return Unsafe.As<int, float>(ref hash);