-
Notifications
You must be signed in to change notification settings - Fork 167
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
Code modernize C++17, refactor and minor optimize #1860
Changes from 2 commits
c491dd4
1fc1801
1c71b64
c48328f
d20e9d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,8 +69,8 @@ class CGrepEnumKeys { | |
} | ||
|
||
// 除外ファイルの2つの解析済み配列から1つのリストを作る | ||
auto GetExcludeFiles() const -> std::list<decltype(m_vecExceptFileKeys)::value_type> { | ||
std::list<decltype(m_vecExceptFileKeys)::value_type> excludeFiles; | ||
auto GetExcludeFiles() const -> std::vector<decltype(m_vecExceptFileKeys)::value_type> { | ||
std::vector<decltype(m_vecExceptFileKeys)::value_type> excludeFiles; | ||
const auto& fileKeys = m_vecExceptFileKeys; | ||
excludeFiles.insert( excludeFiles.cend(), fileKeys.cbegin(), fileKeys.cend() ); | ||
const auto& absFileKeys = m_vecExceptAbsFileKeys; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. auto excludeFiles = m_vecExceptFileKeys;
excludeFiles.reserve(excludeFiles.size() + m_vecExceptFileKeys.size());
excludeFiles.insert( excludeFiles.cend(), m_vecExceptFileKeys.cbegin(), m_vecExceptFileKeys.cend() );
return excludeFiles; こういう記述でも良いと思います。 コンテナの要素を全部追加する関数とかは標準では無いんですよね。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 素っ頓狂なことを言うかもですがstd::copyが標準関数にあたるんじゃないかと思いました。 std::copy( m_vecExceptFileKeys.cbegin(), m_vecExceptFileKeys.cend(), std::back_inserter(excludeFiles) ); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 全体をコピーする場合にわざわざ範囲指定したくないですが、範囲指定が必要な場合もあるので指定するI/Fの処理が標準であるんでしょうね。 記述量を減らしたいならそそもC++を使うべきでないという気もしますが、書く手間が掛かる言語だなぁと思いました。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 実は、コピー自体不要になってるかもです・・・。 std::vector を std::list に変換するメンバー関数だったんですが、 |
||
|
@@ -79,8 +79,8 @@ class CGrepEnumKeys { | |
} | ||
|
||
// 除外フォルダーの2つの解析済み配列から1つのリストを作る | ||
auto GetExcludeFolders() const -> std::list<decltype(m_vecExceptFolderKeys)::value_type> { | ||
std::list<decltype(m_vecExceptFolderKeys)::value_type> excludeFolders; | ||
auto GetExcludeFolders() const -> std::vector<decltype(m_vecExceptFolderKeys)::value_type> { | ||
std::vector<decltype(m_vecExceptFolderKeys)::value_type> excludeFolders; | ||
const auto& folderKeys = m_vecExceptFolderKeys; | ||
excludeFolders.insert( excludeFolders.cend(), folderKeys.cbegin(), folderKeys.cend() ); | ||
const auto& absFolderKeys = m_vecExceptAbsFolderKeys; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(日本語ですみません)
Grep周りは、GUIでもフォルダパスなどにMAX_PATHの倍の長さ(約510文字)を入力できます。
またコマンドライン経由でGrepを起動すれば、もっと長いパスも受け付けます。
実際に、\\?\のUNC形式などを使用すると、Windows10の長いパス対応でなくても、MAX_PATHを超えるパスでGrepすることが可能なはずです。近年の新規コードで制限が増えていなければですが。
ここでMAX_PATH制限をすることは、適切だとは思えません。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テキトーな上限値
4096 - 1
を設定してみました。