public void AddBranch() { int branchHash = _movie.BranchHashByIndex(_movie.BranchCount - 1); foreach (KeyValuePair <int, StateManagerState> kvp in States) { if (!BranchStates.ContainsKey(kvp.Key)) { BranchStates.Add(kvp.Key, new SortedList <int, StateManagerState>()); } SortedList <int, StateManagerState> stateList = BranchStates[kvp.Key]; if (stateList == null) // when does this happen? { stateList = new SortedList <int, StateManagerState>(); BranchStates[kvp.Key] = stateList; } stateList.Add(branchHash, kvp.Value); // We aren't creating any new states, just adding a reference to an already-existing one; so Used doesn't need to be updated. } }
public void AddBranch() { int branchHash = _movie.BranchHashByIndex(_movie.BranchCount - 1); foreach (KeyValuePair <int, StateManagerState> kvp in States) { if (!BranchStates.ContainsKey(kvp.Key)) { BranchStates.Add(kvp.Key, new SortedList <int, StateManagerState>()); } SortedList <int, StateManagerState> stateList = BranchStates[kvp.Key]; if (stateList == null) // when does this happen? { stateList = new SortedList <int, StateManagerState>(); BranchStates[kvp.Key] = stateList; } stateList.Add(branchHash, kvp.Value); Used += (ulong)stateList[branchHash].Length; } }