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,5 +1,6 @@
using Cryville.Common;
using Cryville.Common.Buffers;
using Cryville.Common.Collections.Specialized;
using Cryville.Common.Pdt;
using System;
using System.Collections.Generic;
@@ -82,7 +83,7 @@ namespace Cryville.Crtr {
}
#endregion
#region Judge
internal readonly Dictionary<int, int> judgeMap = new Dictionary<int, int>();
internal readonly IntKeyedDictionary<int> judgeMap = new IntKeyedDictionary<int>();
void InitJudges() {
foreach (var i in _rs.judges) {
var id = i.Key;
@@ -215,15 +216,15 @@ namespace Cryville.Crtr {
}
#endregion
#region Score
readonly Dictionary<int, int> scoreStringKeys = new Dictionary<int, int>();
readonly Dictionary<int, int> scoreStringKeysRev = new Dictionary<int, int>();
readonly Dictionary<int, PropSrc> scoreSrcs = new Dictionary<int, PropSrc>();
readonly Dictionary<int, PropOp> scoreOps = new Dictionary<int, PropOp>();
readonly Dictionary<int, ScoreDefinition> scoreDefs = new Dictionary<int, ScoreDefinition>();
readonly Dictionary<int, float> scores = new Dictionary<int, float>();
readonly Dictionary<int, string> scoreStringCache = new Dictionary<int, string>();
readonly IntKeyedDictionary<int> scoreStringKeys = new IntKeyedDictionary<int>();
readonly IntKeyedDictionary<int> scoreStringKeysRev = new IntKeyedDictionary<int>();
readonly IntKeyedDictionary<PropSrc> scoreSrcs = new IntKeyedDictionary<PropSrc>();
readonly IntKeyedDictionary<PropOp> scoreOps = new IntKeyedDictionary<PropOp>();
readonly IntKeyedDictionary<ScoreDefinition> scoreDefs = new IntKeyedDictionary<ScoreDefinition>();
readonly IntKeyedDictionary<float> scores = new IntKeyedDictionary<float>();
readonly IntKeyedDictionary<string> scoreStringCache = new IntKeyedDictionary<string>();
readonly ArrayPool<byte> scoreStringPool = new ArrayPool<byte>();
readonly Dictionary<int, string> scoreFormatCache = new Dictionary<int, string>();
readonly IntKeyedDictionary<string> scoreFormatCache = new IntKeyedDictionary<string>();
readonly TargetString scoreFullStr = new TargetString();
readonly StringBuffer scoreFullBuf = new StringBuffer();
void InitScores() {