Use std::unordered_set instead of std::vector for res information #61
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.
#59 の修正版です。
このプルリクエストは #53 を修正するパッチの一部です。
定数
MAX_RESNUMBER
によって定められているレス数の上限を取り除くため、std::vector<char>
で管理しているしおりなどのレス情報をレス番号(int)をキーにしたstd::unordered_set<int>
で管理します。修正の根拠
しおり、書き込み、返信などのマークはレス数に対して十分少なくなるはずです。
したがって
std::vector
を使ってレス数と同じサイズの領域を確保する必要性は低いと考えられるのでハッシュセットにレス番号を記録する方法へ変更します。パフォーマンスの影響
挿入時にハッシュ計算(レス番号=int)のコストがかかります。また、最悪の場合はハッシュの再計算や挿入時にメモリの再確保が発生します。
レス情報が増加するほど
std::vector
と比べてメモリ使用量が多くなります。レス番号の順序が必要な箇所がありますが実行される条件は限られている(プロパティのあぼ〜ん設定)ので
std::set<int>
の一時変数を使っています。