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.
@taro-yamada 氏の長大なスレッド(>11000レス?)を開くと落ちる不具合を修正するの修正v1( https://github.com/taro-yamada/JDim/tree/41306cfb )に2つの変更を追加します。
変更の内容 (コミットメッセージ)
[WIP] Use std::unordered_set instead of std::vector for res information
レス数の上限を取り除くため
std::vector<char>
で管理しているしおりなどのレス情報をレス番号(int)をキーにしたstd::unordered_set<int>
で管理します。unordered_set
は初期化の際にkExpectedResInfo
(=512)のサイズに予約します。修正の根拠
しおり、書き込み、返信などのマークはレス数に対して十分少なくなるはずです。したがって
std::vector
でレス数と同じサイズの領域を確保する必要性は低いと考えられます。パフォーマンスの影響
挿入時にハッシュ計算(レス番号=int)のコストがかかります。また、最悪の場合ハッシュの再計算やメモリの再確保が発生します(
kExpectedResInfo
で調整可能)。レス番号の順序が必要な箇所がありますが実行される条件は限られているのでstd::set<int>
の一時変数を使っています。[WIP] Eliminate MAX_RESNUMBER
MAX_RESNUMBER
を取り除いてレス数の上限を1048576(2の20乗)に引き上げます。合わせて7桁までのレスアンカーを有効にします。
また、レス番号を表現する符号付き整数は
sizeof(int) >= 4
以上を要件とします。新たに導入する定数
kMaxResNumber
は設定可能な最大レス数(=1048576) : 設定の上限に使われるkExptectedResNumber
は最大レス数の想定値(=11000) : メモリ確保に使われる