Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::unordered_set instead of std::vector for res information #61

Merged

Conversation

ma8ma
Copy link
Collaborator

@ma8ma ma8ma commented Mar 21, 2019

#59 の修正版です。
このプルリクエストは #53 を修正するパッチの一部です。

定数MAX_RESNUMBERによって定められているレス数の上限を取り除くため、std::vector<char>で管理しているしおりなどのレス情報をレス番号(int)をキーにしたstd::unordered_set<int>で管理します。

修正の根拠

しおり、書き込み、返信などのマークはレス数に対して十分少なくなるはずです。
したがってstd::vectorを使ってレス数と同じサイズの領域を確保する必要性は低いと考えられるのでハッシュセットにレス番号を記録する方法へ変更します。

パフォーマンスの影響

挿入時にハッシュ計算(レス番号=int)のコストがかかります。また、最悪の場合はハッシュの再計算や挿入時にメモリの再確保が発生します。
レス情報が増加するほどstd::vectorと比べてメモリ使用量が多くなります。
レス番号の順序が必要な箇所がありますが実行される条件は限られている(プロパティのあぼ〜ん設定)のでstd::set<int>の一時変数を使っています。

定数MAX_RESNUMBERによって定められているレス数の上限を取り除くため
std::vector<char>で管理しているしおりなどのレス情報を
レス番号(int)をキーにしたstd::unordered_set<int>で管理する。

修正の根拠
しおり、書き込み、返信などのマークはレス数に対して十分少なくなるはず。
したがってstd::vectorを使ってレス数と同じサイズの領域を確保する必要性は
低いと考えられるのでハッシュセットにレス番号を記録する方法へ変更する。

パフォーマンスの影響
挿入時にハッシュ計算(レス番号=int)のコストがかかる。また、最悪の場合
ハッシュの再計算や挿入時にメモリの再確保が発生する。
レス情報が増加するほどstd::vectorと比べてメモリ使用量が多くなる。
レス番号の順序が必要な箇所があるが実行される条件は限られている
(プロパティのあぼ〜ん設定)のでstd::set<int>の一時変数を使っている。
@ma8ma ma8ma added the feature 機能の追加と削除 label Mar 21, 2019
@ma8ma ma8ma added this to In progress in State of JDim-v0.1.0+ via automation Mar 21, 2019
@ma8ma ma8ma mentioned this pull request Mar 21, 2019
@yama-natuki yama-natuki merged commit dec7c9e into JDimproved:master Mar 22, 2019
State of JDim-v0.1.0+ automation moved this from In progress to Done Mar 22, 2019
@yama-natuki
Copy link
Collaborator

ありがとうございます。

@ma8ma ma8ma deleted the use-std-unordered_set-for-res-info branch March 22, 2019 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 機能の追加と削除
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants