This repository was archived by the owner on Apr 17, 2024. It is now read-only.
refactor: use dict instead of lists#126
Merged
Timothy-Liuxf merged 6 commits intoeesast:devfrom Feb 7, 2022
Merged
Conversation
| public Dictionary<uint, BirthPoint> BirthPointList => birthPointList; | ||
|
|
||
| private Dictionary<String, IList<IGameObj>> gameObjDict; | ||
| public Dictionary<String, IList<IGameObj>> GameObjDict => gameObjDict; |
Member
There was a problem hiding this comment.
感觉,这里用一个枚举去作为索引会不会比字符串好一些,例如字符串可能会写错一个字母之类的,编译的时候检查不出来;另外用字符串作为索引也会稍慢
| public ReaderWriterLockSlim GemListLock => gemListLock; | ||
|
|
||
| private readonly Dictionary<uint, BirthPoint> birthPointList; // 出生点列表 | ||
| public Dictionary<uint, BirthPoint> BirthPointList => birthPointList; |
Timothy-Liuxf
previously approved these changes
Feb 7, 2022
Timothy-Liuxf
previously approved these changes
Feb 7, 2022
| gameObjDict.Add(GameObjIdx.Gem, new List<IGameObj>()); | ||
| gameObjLockDict.Add(GameObjIdx.Gem, new ReaderWriterLockSlim()); | ||
| gameObjDict.Add(GameObjIdx.Map, new List<IGameObj>()); | ||
| gameObjLockDict.Add(GameObjIdx.Map, new ReaderWriterLockSlim()); |
Member
There was a problem hiding this comment.
其实这里有一种更方便的方式:
foreach (GameObjIdx idx in Enum.GetValues(typeof(GameObjIdx)))
{
if (idx != GameObjIdx.Null)
{
gameObjDict.Add(idx, new List<IGameObj>());
gameObjLockDict.Add(idx, new ReaderWriterLockSlim());
}
}
Timothy-Liuxf
approved these changes
Feb 7, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Discriptions of this pull request:
No additional discription.