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,3 +1,4 @@
using Cryville.Common.Collections.Specialized;
using Cryville.Common.Pdt;
using System.Collections.Generic;
using UnityEngine;
@@ -9,7 +10,7 @@ namespace Cryville.Crtr {
readonly SkinElement _rootElement;
readonly DynamicStack[] _stacks = new DynamicStack[2];
readonly HashSet<SkinPropertyKey> _once = new HashSet<SkinPropertyKey>();
public readonly Dictionary<int, SkinVariable> Variables = new Dictionary<int, SkinVariable>();
public readonly IntKeyedDictionary<SkinVariable> Variables = new IntKeyedDictionary<SkinVariable>();
class DynamicStack {
public readonly List<DynamicProperty> Properties = new List<DynamicProperty>();
@@ -167,8 +168,8 @@ namespace Cryville.Crtr {
}
public class SkinContext {
public Transform Transform { get; private set; }
public Dictionary<int, PropSrc> PropSrcs { get; private set; }
public SkinContext(Transform transform, Dictionary<int, PropSrc> propSrcs = null) {
public IReadOnlyDictionary<int, PropSrc> PropSrcs { get; private set; }
public SkinContext(Transform transform, IReadOnlyDictionary<int, PropSrc> propSrcs = null) {
Transform = transform;
PropSrcs = propSrcs;
}