Fixes dictionary uses (#7)

This commit is contained in:
Kamron Batman 2018-11-02 08:16:42 -07:00 • committed by GitHub
parent d4a52344f2
commit 916d404c51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
161 changed files with 1211 additions and 1722 deletions

View file

@ -125,16 +125,12 @@ namespace Server
if (itemMap == null || itemMap == Map.Internal)
continue;
Dictionary<Point2D, DeltaState> table = mapTable[itemMap];
if (table == null)
if (!mapTable.TryGetValue(itemMap, out Dictionary<Point2D, DeltaState> table))
mapTable[itemMap] = table = new Dictionary<Point2D, DeltaState>();
Point2D p = new Point2D(item.X >> 3, item.Y >> 3);
DeltaState state = table[p];
if (state == null)
if (!table.TryGetValue(p, out DeltaState state))
table[p] = state = new DeltaState(p);
state.m_List.Add(item);
@ -159,16 +155,12 @@ namespace Server
if (itemMap == null || itemMap == Map.Internal)
continue;
Dictionary<Point2D, DeltaState> table = mapTable[itemMap];
if (table == null)
if (!mapTable.TryGetValue(itemMap, out Dictionary<Point2D, DeltaState> table))
mapTable[itemMap] = table = new Dictionary<Point2D, DeltaState>();
Point2D p = new Point2D(item.X >> 3, item.Y >> 3);
DeltaState state = table[p];
if (state == null)
if (!table.TryGetValue(p, out DeltaState state))
table[p] = state = new DeltaState(p);
state.m_List.Add(item);