Skip to content

Commit 834dea4

Browse files
committed
Code improvement
1 parent c8478a9 commit 834dea4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

IExplorerCommand_CppWinRT/dllmain.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ BOOL APIENTRY DllMain(_In_ HMODULE hModule, _In_ DWORD ul_reason_for_call, _In_
2121
}
2222

2323
namespace {
24+
2425
// Extracted from
2526
// https://source.chromium.org/chromium/chromium/src/+/main:base/command_line.cc;l=109-159
26-
2727
std::wstring QuoteForCommandLineArg(_In_ const std::wstring& arg) {
2828
// We follow the quoting rules of CommandLineToArgvW.
2929
// http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
30-
std::wstring quotable_chars(L" \\\"");
30+
const std::wstring quotable_chars(L" \\\"");
3131
if (arg.find_first_of(quotable_chars) == std::wstring::npos) {
3232
// No quoting necessary.
3333
return arg;
@@ -38,7 +38,8 @@ namespace {
3838
for (size_t i = 0; i < arg.size(); ++i) {
3939
if (arg[i] == '\\') {
4040
// Find the extent of this run of backslashes.
41-
size_t start = i, end = start + 1;
41+
const size_t start = i;
42+
size_t end = start + 1;
4243
for (; end < arg.size() && arg[end] == '\\'; ++end) {}
4344
size_t backslash_count = end - start;
4445

IExplorerCommand_WRL/dllmain.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ BOOL APIENTRY DllMain(_In_ HMODULE hModule, _In_ DWORD ul_reason_for_call, _In_
3131
}
3232

3333
namespace {
34+
3435
// Extracted from
3536
// https://source.chromium.org/chromium/chromium/src/+/main:base/command_line.cc;l=109-159
36-
3737
std::wstring QuoteForCommandLineArg(_In_ const std::wstring& arg) {
3838
// We follow the quoting rules of CommandLineToArgvW.
3939
// http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
40-
std::wstring quotable_chars(L" \\\"");
40+
const std::wstring quotable_chars(L" \\\"");
4141
if (arg.find_first_of(quotable_chars) == std::wstring::npos) {
4242
// No quoting necessary.
4343
return arg;
@@ -48,7 +48,8 @@ namespace {
4848
for (size_t i = 0; i < arg.size(); ++i) {
4949
if (arg[i] == '\\') {
5050
// Find the extent of this run of backslashes.
51-
size_t start = i, end = start + 1;
51+
const size_t start = i;
52+
size_t end = start + 1;
5253
for (; end < arg.size() && arg[end] == '\\'; ++end) {}
5354
size_t backslash_count = end - start;
5455

0 commit comments

Comments
 (0)