Repository: microsoft/terminal
File: src/cascadia/TerminalControl/TermControl.cpp (C++)

Code before:
                        const auto count = DragQueryFile((HDROP)hGlobal, 0xFFFFFFFF, nullptr, 0);
                        fullPaths.reserve(count);

                        for (unsigned int i = 0; i < count; i++)
                        {
                            WCHAR szPath[MAX_PATH];
                            const auto charsCopied = DragQueryFile((HDROP)hGlobal, i, szPath, MAX_PATH);

                            if (charsCopied > 0)
                            {
                                fullPaths.push_back(std::wstring{ szPath });
                            }
                        }
                    }
                }
                else
                {
                    fullPaths.reserve(items.Size());
                    for (auto item : items)
                    {
                        fullPaths.push_back(std::wstring{ item.Path() });
                    }
                }

                std::wstring allPathsString;
                for (auto fullPath : fullPaths)
                {
                    // Join the paths with spaces
                    if (!allPathsString.empty())
                    {
                        allPathsString += L" ";
                    }

                    // Fix path for WSL
                    // In the fullness of time, we should likely plumb this up
                    // to the TerminalApp layer, and have it make the decision
                    // if this control should have it's path mangled (and do the
                    // mangling), rather than exposing the source concept to the
                    // Control layer.
                    //
                    // However, it's likely that the control layer may need to
                    // know about the source anyways in the future, to support
                    // GH#3158
                    if (_interactivity.ManglePathsForWsl())
                    {
                        std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/');

                        if (fullPath.size() >= 2 && fullPath.at(1) == L':')
                        {
                            // C:/foo/bar -> Cc/foo/bar
                            fullPath.at(1) = til::tolower_ascii(fullPath.at(0));

Review comment (suggestion):
```suggestion
                for (auto& fullPath : fullPaths)
```

No point taking an extra copy if we don't need to!

Code after:
                        const auto count = DragQueryFileW(static_cast<HDROP>(hGlobal), 0xFFFFFFFF, nullptr, 0);
                        fullPaths.reserve(count);

                        for (unsigned int i = 0; i < count; i++)
                        {
                            std::wstring path;
                            path.resize(wil::max_path_length);
                            const auto charsCopied = DragQueryFileW(static_cast<HDROP>(hGlobal), i, path.data(), wil::max_path_length);

                            if (charsCopied > 0)
                            {
                                path.resize(charsCopied);
                                fullPaths.emplace_back(std::move(path));
                            }
                        }
                    }
                }
                else
                {
                    fullPaths.reserve(items.Size());
                    for (const auto& item : items)
                    {
                        fullPaths.emplace_back(item.Path());
                    }
                }

                std::wstring allPathsString;
                for (auto& fullPath : fullPaths)
                {
                    // Join the paths with spaces
                    if (!allPathsString.empty())
                    {
                        allPathsString += L" ";
                    }

                    // Fix path for WSL
                    // In the fullness of time, we should likely plumb this up
                    // to the TerminalApp layer, and have it make the decision
                    // if this control should have it's path mangled (and do the
                    // mangling), rather than exposing the source concept to the
                    // Control layer.
                    //
                    // However, it's likely that the control layer may need to
                    // know about the source anyways in the future, to support
                    // GH#3158
                    if (_interactivity.ManglePathsForWsl())
                    {
                        std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/');

                        if (fullPath.size() >= 2 && fullPath.at(1) == L':')
                        {