Skip to content

Conversation

@gorogoro123
Copy link
Contributor

PR対象

  • アプリ(サクラエディタ本体)

カテゴリ

  • 改善

PR の背景

C++11 から range-based for loop が使用できるので、簡潔に記述できる。

仕様・動作説明

  1. range-based for loop に変更
  2. push_back() -> emplace_back() に変更

PR の影響範囲

影響なし。

テスト内容

  1. 変更前後で、sakura.ini を比較する。
    デバッガの引数に "-NOWIN" を追加
    タスクトレイから、サクラエディタの全終了を選択
  2. CProfile::DUMP() を呼び出してdump内容を確認する。

関連 issue, PR

#1733
#416

参考資料

https://cpprefjp.github.io/lang/cpp11/range_based_for.html

@beru beru added the refactoring リファクタリング 【ChangeLog除外】 label Sep 8, 2025
Copy link
Contributor

@berryzplus berryzplus left a comment

Choose a reason for hiding this comment

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

対応ありがとうございます。

for(const auto& iter : m_ProfileData) {
MYTRACE( L"\n■strSectionName=%ls", iter.strSectionName.c_str() );
for(const auto& mapiter : iter.mapEntries) {
MYTRACE( L"\"%ls\" = \"%ls\"\n", mapiter.first.c_str(), mapiter.second.c_str() );
Copy link
Contributor

@berryzplus berryzplus Oct 8, 2025

Choose a reason for hiding this comment

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

引っかかる余地があるのはここだけと思いますが、C++11対応をうたっているので問題なしと思います。
(「mapのkey-value列挙にはC++17の構造化束縛を使おう」の指摘はあり得る。)

vecLine.push_back( LTEXT("") );
}
for(auto iter = m_ProfileData.cbegin(); iter != m_ProfileData.cend(); iter++ ) {
for(const auto& iter : m_ProfileData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

変更後はこの変数は iterator ではないと思うのでちょっと変数名に違和感があります。まぁ細かい事を言い出すときりが無いですが。

Copy link
Contributor

Choose a reason for hiding this comment

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

マジメにネーミングすると seciton ですね。

プロファイル
┗セクション1
 ┣キー1 = 値1
 ┣キー2 = 値2
 ┗キー3 = 値3

という構造。セクションは配列(vector)、セクション内のkey-valueはマップ(map)なので
線形イテレーターの iter 、マップイテレーターの mapIter という変数名にしたものと思われます。

Copy link
Contributor

@beru beru left a comment

Choose a reason for hiding this comment

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

問題無いと思います。

@beru beru merged commit 9dd96a3 into sakura-editor:master Nov 9, 2025
12 of 14 checks passed
@gorogoro123 gorogoro123 deleted the feature/apply_cpp11_range_based_for_loop_CProfile branch November 9, 2025 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring リファクタリング 【ChangeLog除外】

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants