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

Code before:
// flow, but not too quick to see
static const int AnimationDurationInMilliseconds = 200;
static const Duration AnimationDuration = DurationHelper::FromTimeSpan(winrt::Windows::Foundation::TimeSpan(std::chrono::milliseconds(AnimationDurationInMilliseconds)));

Pane::Pane(const IPaneContent& content, const bool lastFocused) :
    _content{ content },
    _lastActive{ lastFocused }
{
    _root.Children().Append(_borderFirst);

    const auto& control{ _content.GetRoot() };
    _borderFirst.Child(control);

    // Register an event with the control to have it inform us when it gains focus.
    if (control)
    {
        _gotFocusRevoker = control.GotFocus(winrt::auto_revoke, { this, &Pane::_ContentGotFocusHandler });
        _lostFocusRevoker = control.LostFocus(winrt::auto_revoke, { this, &Pane::_ContentLostFocusHandler });
    }

    // When our border is tapped, make sure to transfer focus to our control.
    // LOAD-BEARING: This will NOT work if the border's BorderBrush is set to
    // Colors::Transparent! The border won't get Tapped events, and they'll fall
    // through to something else.
    _borderFirst.Tapped([this](auto& s, auto& e) { _borderTappedHandler(s, e); });
    _borderSecond.Tapped([this](auto& s, auto& e) { _borderTappedHandler(s, e); });
}

Pane::Pane(std::shared_ptr<Pane> first,
           std::shared_ptr<Pane> second,
           const SplitState splitState,
           const float splitPosition,
           const bool lastFocused) :
    _firstChild{ first },
    _secondChild{ second },
    _splitState{ splitState },
    _desiredSplitPosition{ splitPosition },
    _lastActive{ lastFocused }
{
    _CreateRowColDefinitions();
    _borderFirst.Child(_firstChild->GetRootElement());
    _borderSecond.Child(_secondChild->GetRootElement());

    // Use the unfocused border color as the pane background, so an actual color
    // appears behind panes as we animate them sliding in.
    _root.Background(_themeResources.unfocusedBorderBrush);

    _root.Children().Append(_borderFirst);
    _root.Children().Append(_borderSecond);

    _ApplySplitDefinitions();

Review comment (performance):
```suggestion
    _borderFirst.Tapped({ this, _borderTappedHandler });
    _borderSecond.Tapped({ this, _borderTappedHandler });
```
The construction without a lambda is more efficient, technically. But it's also a bit easier to read IMO.

Code after:
// flow, but not too quick to see
static const int AnimationDurationInMilliseconds = 200;
static const Duration AnimationDuration = DurationHelper::FromTimeSpan(winrt::Windows::Foundation::TimeSpan(std::chrono::milliseconds(AnimationDurationInMilliseconds)));

Pane::Pane(const IPaneContent& content, const bool lastFocused) :
    _content{ content },
    _lastActive{ lastFocused }
{
    _root.Children().Append(_borderFirst);

    const auto& control{ _content.GetRoot() };
    _borderFirst.Child(control);

    // Register an event with the control to have it inform us when it gains focus.
    if (control)
    {
        _gotFocusRevoker = control.GotFocus(winrt::auto_revoke, { this, &Pane::_ContentGotFocusHandler });
        _lostFocusRevoker = control.LostFocus(winrt::auto_revoke, { this, &Pane::_ContentLostFocusHandler });
    }

    // When our border is tapped, make sure to transfer focus to our control.
    // LOAD-BEARING: This will NOT work if the border's BorderBrush is set to
    // Colors::Transparent! The border won't get Tapped events, and they'll fall
    // through to something else.
    _borderFirst.Tapped({ this, &Pane::_borderTappedHandler });
    _borderSecond.Tapped({ this, &Pane::_borderTappedHandler });
}

Pane::Pane(std::shared_ptr<Pane> first,
           std::shared_ptr<Pane> second,
           const SplitState splitState,
           const float splitPosition,
           const bool lastFocused) :
    _firstChild{ first },
    _secondChild{ second },
    _splitState{ splitState },
    _desiredSplitPosition{ splitPosition },
    _lastActive{ lastFocused }
{
    _CreateRowColDefinitions();
    _borderFirst.Child(_firstChild->GetRootElement());
    _borderSecond.Child(_secondChild->GetRootElement());

    // Use the unfocused border color as the pane background, so an actual color
    // appears behind panes as we animate them sliding in.
    _root.Background(_themeResources.unfocusedBorderBrush);

    _root.Children().Append(_borderFirst);
    _root.Children().Append(_borderSecond);

    _ApplySplitDefinitions();