Repository: microsoft/terminal
File: src/cascadia/TerminalApp/AppActionHandlers.cpp (C++)

Code before:
        {
            args.Handled(false);
        }
        else if (const auto& realArgs = args.ActionArgs().try_as<SendInputArgs>())
        {
            if (const auto termControl{ _GetActiveControl() })
            {
                termControl.SendInput(realArgs.Input());
                args.Handled(true);
            }
        }
    }

    void TerminalPage::_HandleCloseOtherPanes(const IInspectable& /*sender*/,
                                              const ActionEventArgs& args)
    {
        if (const auto terminalTab{ _GetFocusedTabImpl() })
        {
            const auto activePane = terminalTab->GetActivePane();
            if (terminalTab->GetRootPane() != activePane)
            {
                _UnZoomIfNeeded();

                // Accumulate list of all unfocused leaf panes
                std::deque<uint32_t> unfocusedPaneIds{};
                terminalTab->GetRootPane()->WalkTree([&](auto p) {
                    const auto id = p->Id();
                    if (id.has_value() && id != activePane->Id())
                    {
                        unfocusedPaneIds.push_back(id.value());
                    }
                });

                // Start by removing the panes that were least recently added
                sort(begin(unfocusedPaneIds), end(unfocusedPaneIds), std::greater<uint32_t>());
                _CloseUnfocusedPanes(terminalTab->get_weak(), std::move(unfocusedPaneIds));
            }
        }
        args.Handled(true);
    }

    void TerminalPage::_HandleMovePane(const IInspectable& /*sender*/,
                                       const ActionEventArgs& args)
    {
        if (args == nullptr)
        {
            args.Handled(false);
        }
        else if (const auto& realArgs = args.ActionArgs().try_as<MovePaneArgs>())
        {
            auto moved = _MovePane(realArgs.TabIndex());

Review comment (performance):
```suggestion
                std::vector<uint32_t> unfocusedPaneIds;
                terminalTab->GetRootPane()->WalkTree([&](auto&& p) {
```

If you then replace `std::greater` with `std::less` and `front`/`pop_front` with `back`/`pop_back` you can use a more efficient container.

Code after:
        {
            args.Handled(false);
        }
        else if (const auto& realArgs = args.ActionArgs().try_as<SendInputArgs>())
        {
            if (const auto termControl{ _GetActiveControl() })
            {
                termControl.SendInput(realArgs.Input());
                args.Handled(true);
            }
        }
    }

    void TerminalPage::_HandleCloseOtherPanes(const IInspectable& /*sender*/,
                                              const ActionEventArgs& args)
    {
        if (const auto terminalTab{ _GetFocusedTabImpl() })
        {
            const auto activePane = terminalTab->GetActivePane();
            if (terminalTab->GetRootPane() != activePane)
            {
                _UnZoomIfNeeded();

                // Accumulate list of all unfocused leaf panes, ignore read-only panes
                std::vector<uint32_t> unfocusedPaneIds;
                const auto activePaneId = activePane->Id();
                terminalTab->GetRootPane()->WalkTree([&](auto&& p) {
                    const auto id = p->Id();
                    if (id.has_value() && id != activePaneId && !p->ContainsReadOnly())
                    {
                        unfocusedPaneIds.push_back(id.value());
                    }
                });

                if (!empty(unfocusedPaneIds))
                {
                    // Start by removing the panes that were least recently added
                    sort(begin(unfocusedPaneIds), end(unfocusedPaneIds), std::less<uint32_t>());
                    _ClosePanes(terminalTab->get_weak(), std::move(unfocusedPaneIds));
                    args.Handled(true);
                    return;
                }
            }
            args.Handled(false);
        }
    }

    void TerminalPage::_HandleMovePane(const IInspectable& /*sender*/,
                                       const ActionEventArgs& args)
    {
        if (args == nullptr)