Repository: microsoft/terminal
File: src/cascadia/TerminalApp/TerminalWindow.h (C/C++)

Code before:

    public:
        SystemMenuChangeArgs(const winrt::hstring& name, SystemMenuChangeAction action, SystemMenuItemHandler handler = nullptr) :
            _Name{ name }, _Action{ action }, _Handler{ handler } {};
    };

    struct WindowProperties : WindowPropertiesT<WindowProperties>
    {
        // Normally, WindowName and WindowId would be
        // WINRT_OBSERVABLE_PROPERTY's, but we want them to raise
        // WindowNameForDisplay and WindowIdForDisplay instead
        winrt::hstring WindowName() const noexcept;
        void WindowName(const winrt::hstring& value);
        uint64_t WindowId() const noexcept;
        void WindowId(const uint64_t& value);
        winrt::hstring WindowIdForDisplay() const noexcept;
        winrt::hstring WindowNameForDisplay() const noexcept;
        bool IsQuakeWindow() const noexcept;

        WINRT_OBSERVABLE_PROPERTY(winrt::hstring, VirtualWorkingDirectory, _PropertyChangedHandlers, L"");

        WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);

    public:
        // Used for setting the initial CWD, before we have XAML set up for property change notifications.
        void SetInitialCwd(const winrt::hstring& cwd) { _VirtualWorkingDirectory = cwd; };

    private:
        winrt::hstring _WindowName{};
        uint64_t _WindowId{ 0 };
    };

    struct TerminalWindow : TerminalWindowT<TerminalWindow, IInitializeWithWindow>
    {
    public:
        TerminalWindow(const TerminalApp::SettingsLoadEventArgs& settingsLoadedResult, const TerminalApp::ContentManager& manager);
        ~TerminalWindow() = default;

        STDMETHODIMP Initialize(HWND hwnd);

        void Create();

        void Quit();

        winrt::fire_and_forget UpdateSettings(winrt::TerminalApp::SettingsLoadEventArgs args);

        bool HasCommandlineArguments() const noexcept;

        int32_t SetStartupCommandline(array_view<const winrt::hstring> actions, winrt::hstring cwd);
        void SetStartupContent(const winrt::hstring& content, const Windows::Foundation::IReference<Windows::Foundation::Rect>& contentBounds);
        int32_t ExecuteCommandline(array_view<const winrt::hstring> actions, const winrt::hstring& cwd);

Review comment (suggestion):
If you take the hstring by value you can use `std::move()` it into place without addref/release cycles. The same is true for `SetStartupCommandline`. Additionally, I'd move the implementation of this function outside of the header file.

Code after:

    public:
        SystemMenuChangeArgs(const winrt::hstring& name, SystemMenuChangeAction action, SystemMenuItemHandler handler = nullptr) :
            _Name{ name }, _Action{ action }, _Handler{ handler } {};
    };

    struct WindowProperties : WindowPropertiesT<WindowProperties>
    {
        // Normally, WindowName and WindowId would be
        // WINRT_OBSERVABLE_PROPERTY's, but we want them to raise
        // WindowNameForDisplay and WindowIdForDisplay instead
        winrt::hstring WindowName() const noexcept;
        void WindowName(const winrt::hstring& value);
        uint64_t WindowId() const noexcept;
        void WindowId(const uint64_t& value);
        winrt::hstring WindowIdForDisplay() const noexcept;
        winrt::hstring WindowNameForDisplay() const noexcept;
        bool IsQuakeWindow() const noexcept;

        WINRT_OBSERVABLE_PROPERTY(winrt::hstring, VirtualWorkingDirectory, _PropertyChangedHandlers, L"");

        WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);

    public:
        // Used for setting the initial CWD, before we have XAML set up for property change notifications.
        void SetInitialCwd(winrt::hstring cwd) { _VirtualWorkingDirectory = std::move(cwd); };

    private:
        winrt::hstring _WindowName{};
        uint64_t _WindowId{ 0 };
    };

    struct TerminalWindow : TerminalWindowT<TerminalWindow, IInitializeWithWindow>
    {
    public:
        TerminalWindow(const TerminalApp::SettingsLoadEventArgs& settingsLoadedResult, const TerminalApp::ContentManager& manager);
        ~TerminalWindow() = default;

        STDMETHODIMP Initialize(HWND hwnd);

        void Create();

        void Quit();

        winrt::fire_and_forget UpdateSettings(winrt::TerminalApp::SettingsLoadEventArgs args);

        bool HasCommandlineArguments() const noexcept;

        int32_t SetStartupCommandline(array_view<const winrt::hstring> actions, winrt::hstring cwd);
        void SetStartupContent(const winrt::hstring& content, const Windows::Foundation::IReference<Windows::Foundation::Rect>& contentBounds);
        int32_t ExecuteCommandline(array_view<const winrt::hstring> actions, const winrt::hstring& cwd);