37e0614554
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References The `+=` operator is an extremely hot path under heavily output load. This PR aims to optimize its speed. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [ ] Supports #10563 * [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
63 lines
1.6 KiB
C++
63 lines
1.6 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- OutputCellView.hpp
|
|
|
|
Abstract:
|
|
- Read view into a single cell of data that someone is attempting to write into the output buffer.
|
|
- This is done for performance reasons (avoid heap allocs and copies).
|
|
|
|
Author:
|
|
- Michael Niksa (MiNiksa) 06-Oct-2018
|
|
|
|
Revision History:
|
|
- Based on work from OutputCell.hpp/cpp by Austin Diviness (AustDi)
|
|
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
#include "DbcsAttribute.hpp"
|
|
#include "TextAttribute.hpp"
|
|
|
|
class OutputCellView
|
|
{
|
|
public:
|
|
OutputCellView(const std::wstring_view view,
|
|
const DbcsAttribute dbcsAttr,
|
|
const TextAttribute textAttr,
|
|
const TextAttributeBehavior behavior) noexcept;
|
|
|
|
const std::wstring_view& Chars() const noexcept;
|
|
size_t Columns() const noexcept;
|
|
DbcsAttribute DbcsAttr() const noexcept;
|
|
TextAttribute TextAttr() const noexcept;
|
|
TextAttributeBehavior TextAttrBehavior() const noexcept;
|
|
|
|
void UpdateText(const std::wstring_view& view) noexcept
|
|
{
|
|
_view = view;
|
|
};
|
|
|
|
void UpdateDbcsAttribute(const DbcsAttribute& dbcsAttr) noexcept
|
|
{
|
|
_dbcsAttr = dbcsAttr;
|
|
}
|
|
|
|
void UpdateTextAttribute(const TextAttribute& textAttr) noexcept
|
|
{
|
|
_textAttr = textAttr;
|
|
}
|
|
|
|
bool operator==(const OutputCellView& view) const noexcept;
|
|
bool operator!=(const OutputCellView& view) const noexcept;
|
|
|
|
private:
|
|
std::wstring_view _view;
|
|
DbcsAttribute _dbcsAttr;
|
|
TextAttribute _textAttr;
|
|
TextAttributeBehavior _behavior;
|
|
};
|