Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

til::rle<T, S> - a run length encoded storage template #8794

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1ed8ef0
copy rectangle to rle and add to sources.
miniksa Jan 8, 2021
00ca3f2
Clean out the rect stuff and prep for rle stuff.
miniksa Jan 8, 2021
8114fa0
it doesn't quite work yet, but it's what I'm going for.
miniksa Jan 9, 2021
33e9a9b
It compiles!
miniksa Jan 11, 2021
f00ffb0
Get some tests going.
miniksa Jan 13, 2021
a692bb2
more rle
miniksa Jan 13, 2021
67d591b
Iterators and tests.
miniksa Jan 14, 2021
a1c1d5c
Make AttrRow use til::rle directly.
miniksa Jan 14, 2021
b591355
Drop attrrowtests.cpp. It overlaps/is obsoleted by RunLengthEncodingT…
miniksa Jan 14, 2021
c65161d
Let full batch assign through to public. Make AttrRow use it. TextAtt…
miniksa Jan 15, 2021
324c094
spell check
miniksa Jan 15, 2021
69538c4
code format
miniksa Jan 15, 2021
9b8c9d4
substring and hide to_string for non-unit-testing.
miniksa Jan 15, 2021
cdc5a6a
Merge branch 'main' into dev/miniksa/rle
miniksa Mar 24, 2021
4247ece
Merge remote-tracking branch 'origin/main' into dev/miniksa/rle
lhecker Apr 28, 2021
b38286c
sprinkled til::rle with my personal preferences
lhecker Apr 28, 2021
bf3edb5
make the linter happy
lhecker Apr 29, 2021
7ad586e
Major rework of til::rle to add replace()
lhecker May 8, 2021
dd1195a
Fix remaining ATTR_ROW + til::rle bugs
lhecker May 8, 2021
e3242b7
Fixed til::rle when inserting more than one run
lhecker May 9, 2021
06d45cc
Initial test coverage work
lhecker May 9, 2021
5878abd
Added til::rle test suite
lhecker May 10, 2021
b05a117
Fix AuditMode errors
lhecker May 11, 2021
9bdcdca
Remove code redundant with consoletaeftemplates.hpp
lhecker May 11, 2021
db0ab1c
Fix til::rle for run length smaller than int
lhecker May 12, 2021
3f1355d
Improved til::rle::replace documentation
lhecker May 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spell-check/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,7 @@ mutex
mutexes
muxes
myapplet
mybase
mydir
myignite
MYMAX
Expand Down
557 changes: 21 additions & 536 deletions src/buffer/out/AttrRow.cpp

Large diffs are not rendered by default.

46 changes: 12 additions & 34 deletions src/buffer/out/AttrRow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,26 @@ Revision History:

#pragma once

#include "til/rle.h"

#include "TextAttributeRun.hpp"
#include "AttrRowIterator.hpp"

class ATTR_ROW final
class ATTR_ROW final : public til::rle<TextAttribute, UINT>
lhecker marked this conversation as resolved.
Show resolved Hide resolved
{
public:
using const_iterator = typename AttrRowIterator;

ATTR_ROW(const UINT cchRowWidth, const TextAttribute attr)
noexcept;
using mybase = til::rle<TextAttribute, UINT>;

~ATTR_ROW() = default;
using const_iterator = mybase::const_iterator;
using const_reverse_iterator = mybase::const_reverse_iterator;

ATTR_ROW(const ATTR_ROW&) = default;
ATTR_ROW& operator=(const ATTR_ROW&) = default;
ATTR_ROW(ATTR_ROW&&)
noexcept = default;
ATTR_ROW& operator=(ATTR_ROW&&) noexcept = default;
using mybase::mybase; // use base constructor

void Reset(const TextAttribute attr);

TextAttribute GetAttrByColumn(const size_t column) const;
TextAttribute GetAttrByColumn(const size_t column,
size_t* const pApplies) const;
miniksa marked this conversation as resolved.
Show resolved Hide resolved

size_t GetNumberOfRuns() const noexcept;

size_t FindAttrIndex(const size_t index,
size_t* const pApplies) const;

std::vector<uint16_t> GetHyperlinks();

bool SetAttrToEnd(const UINT iStart, const TextAttribute attr);
Expand All @@ -62,22 +52,10 @@ class ATTR_ROW final
const size_t iEnd,
const size_t cBufferWidth);

static std::vector<TextAttributeRun> PackAttrs(const std::vector<TextAttribute>& attrs);

const_iterator begin() const noexcept;
const_iterator end() const noexcept;

const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;

friend bool operator==(const ATTR_ROW& a, const ATTR_ROW& b) noexcept;
friend class AttrRowIterator;

private:
boost::container::small_vector<TextAttributeRun, 1> _list;
size_t _cchRowWidth;
using mybase::begin;
using mybase::cbegin;
using mybase::cend;
using mybase::end;

#ifdef UNIT_TESTING
friend class AttrRowTests;
#endif
using mybase::operator==;
};
32 changes: 13 additions & 19 deletions src/buffer/out/TextAttributeRun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,23 @@ Revision History:

#include "TextAttribute.hpp"

class TextAttributeRun final
class TextAttributeRun final : public std::pair<TextAttribute, unsigned int>
{
public:
TextAttributeRun() = default;
TextAttributeRun(const size_t cchLength, const TextAttribute attr) noexcept :
_cchLength(gsl::narrow<unsigned int>(cchLength))
{
SetAttributes(attr);
}
using mybase = std::pair<TextAttribute, unsigned int>;

size_t GetLength() const noexcept { return _cchLength; }
void SetLength(const size_t cchLength) noexcept { _cchLength = gsl::narrow<unsigned int>(cchLength); }
void IncrementLength() noexcept { _cchLength++; }
void DecrementLength() noexcept { _cchLength--; }
using mybase::mybase;

const TextAttribute& GetAttributes() const noexcept { return _attributes; }
void SetAttributes(const TextAttribute textAttribute) noexcept { _attributes = textAttribute; }
TextAttributeRun(const size_t cchLength, const TextAttribute attr) :
mybase(attr, gsl::narrow<unsigned int>(cchLength))
{
}

private:
unsigned int _cchLength{ 0 };
TextAttribute _attributes{ 0 };
size_t GetLength() const noexcept { return mybase::second; }
void SetLength(const size_t cchLength) noexcept { mybase::second = gsl::narrow<unsigned int>(cchLength); }
void IncrementLength() noexcept { mybase::second++; }
void DecrementLength() noexcept { mybase::second--; }

#ifdef UNIT_TESTING
friend class AttrRowTests;
#endif
const TextAttribute& GetAttributes() const noexcept { return mybase::first; }
void SetAttributes(const TextAttribute textAttribute) noexcept { mybase::first = textAttribute; }
};
2 changes: 0 additions & 2 deletions src/buffer/out/lib/bufferout.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<Import Project="$(SolutionDir)src\common.build.pre.props" />
<ItemGroup>
<ClCompile Include="..\AttrRow.cpp" />
<ClCompile Include="..\AttrRowIterator.cpp" />
<ClCompile Include="..\cursor.cpp" />
<ClCompile Include="..\OutputCell.cpp" />
<ClCompile Include="..\OutputCellIterator.cpp" />
Expand All @@ -35,7 +34,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\AttrRow.hpp" />
<ClInclude Include="..\AttrRowIterator.hpp" />
miniksa marked this conversation as resolved.
Show resolved Hide resolved
<ClInclude Include="..\cursor.h" />
<ClInclude Include="..\DbcsAttribute.hpp" />
<ClInclude Include="..\ICharRow.hpp" />
Expand Down
4 changes: 2 additions & 2 deletions src/buffer/out/textBufferCellIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Author(s):

#pragma once

#include "AttrRowIterator.hpp"
#include "CharRow.hpp"
#include "AttrRow.hpp"
#include "OutputCellView.hpp"
#include "../../types/inc/viewport.hpp"

Expand Down Expand Up @@ -55,7 +55,7 @@ class TextBufferCellIterator
OutputCellView _view;

const ROW* _pRow;
AttrRowIterator _attrIter;
ATTR_ROW::const_iterator _attrIter;
const TextBuffer& _buffer;
const Microsoft::Console::Types::Viewport _bounds;
bool _exceeded;
Expand Down
Loading