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

message_add 関数をC++機能でリファクタリングする #1026 #1028

Merged

Conversation

habu1010
Copy link
Member

@habu1010 habu1010 commented May 4, 2021

#1027 の修正と合わせると、最大81919件のメッセージが保存されるようになり、セーブファイルからメッセージ履歴読み込み時の計算量もO(N log(N))に改善する。
また、人間に理解できるコードになった。
レビューがしやすいように、以下の2つにコミットを分けている。

  • std::dequeを使用したメッセージ履歴の管理の実装
  • 上記を元にstd::shared_ptrを使用した同一メッセージの共有の実装

@habu1010 habu1010 added enhancement New feature or request refactor 処理の整理、可読性の向上 labels May 4, 2021
@habu1010 habu1010 added this to the 3.0.0Alpha22Release milestone May 4, 2021
@habu1010 habu1010 self-assigned this May 4, 2021
@habu1010 habu1010 added this to In Progress in C++移行 via automation May 4, 2021
@habu1010 habu1010 linked an issue May 4, 2021 that may be closed by this pull request
現在のメッセージ履歴の処理は自前でメッセージ保存用リングバッファと
メッセージを指すポインタのリングバッファを管理しており、およそ
人間の読めるコードではない。
dequeとstringを使用して分かりやすく書き直す。
@habu1010 habu1010 force-pushed the feature/refactor-message-history branch 4 times, most recently from b92a423 to 52403b8 Compare May 4, 2021 10:12
sikabane-works
sikabane-works previously approved these changes May 5, 2021
Copy link
Member

@sikabane-works sikabane-works left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

リファクタリング後も変わらず動作することを確認しました。マージをどうぞ。

std::shared_ptr を用いて、同一のメッセージの場合はメッセージ領域を共有する。
メッセージの検索には std::map を使用し、O(log(N))で検索できるようにする。
@habu1010
Copy link
Member Author

habu1010 commented May 5, 2021

make_message の中に 検索用 map オブジェクトへの追加処理を移動することで、検索用 map オブジェクトへの追加とカスタムデリータによる削除が対応しているのが分かりやすくなるようにしました。

Copy link
Member

@sikabane-works sikabane-works left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

マージどうぞ。

@habu1010 habu1010 merged commit 6a3acd9 into hengband:develop May 5, 2021
C++移行 automation moved this from In Progress to Done May 5, 2021
@habu1010 habu1010 deleted the feature/refactor-message-history branch May 5, 2021 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor 処理の整理、可読性の向上
Projects
Development

Successfully merging this pull request may close these issues.

message_add 関数をC++機能でリファクタリングする
2 participants