Skip to content

Commit

Permalink
Fix AuditMode errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed May 11, 2021
1 parent 96d899d commit 1822335
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/buffer/out/AttrRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool ATTR_ROW::SetAttrToEnd(const UINT iStart, const TextAttribute attr)
// - replaceWith - the new value for the matching runs' attributes.
// Return Value:
// - <none>
void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAttribute& replaceWith) noexcept
void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAttribute& replaceWith)
{
_data.replace_values(toBeReplacedAttr, replaceWith);
}
Expand Down
2 changes: 1 addition & 1 deletion src/buffer/out/AttrRow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ATTR_ROW final
std::vector<uint16_t> GetHyperlinks();

bool SetAttrToEnd(const UINT iStart, const TextAttribute attr);
void ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAttribute& replaceWith) noexcept;
void ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAttribute& replaceWith);

void Resize(const size_t newWidth);

Expand Down
2 changes: 1 addition & 1 deletion src/buffer/out/Row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// - pParent - the text buffer that this row belongs to
// Return Value:
// - constructed object
ROW::ROW(const SHORT rowId, const unsigned short rowWidth, const TextAttribute fillAttribute, TextBuffer* const pParent) noexcept :
ROW::ROW(const SHORT rowId, const unsigned short rowWidth, const TextAttribute fillAttribute, TextBuffer* const pParent) :
_id{ rowId },
_rowWidth{ rowWidth },
_charRow{ rowWidth, this },
Expand Down
3 changes: 1 addition & 2 deletions src/buffer/out/Row.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class TextBuffer;
class ROW final
{
public:
ROW(const SHORT rowId, const unsigned short rowWidth, const TextAttribute fillAttribute, TextBuffer* const pParent)
noexcept;
ROW(const SHORT rowId, const unsigned short rowWidth, const TextAttribute fillAttribute, TextBuffer* const pParent);

size_t size() const noexcept { return _rowWidth; }

Expand Down
59 changes: 27 additions & 32 deletions src/inc/til/rle.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
using size_type = S;
using difference_type = typename ParentIt::difference_type;

explicit rle_iterator(ParentIt&& it) :
_it(std::forward<ParentIt>(it)),
_usage(1)
// TODO: Enable checked iterators for _ITERATOR_DEBUG_LEVEL != 0.
explicit rle_iterator(ParentIt&& it) noexcept :
_it{ std::forward<ParentIt>(it) },
_pos{ 1 }
{
}

Expand All @@ -38,35 +39,34 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
return &operator*();
}

rle_iterator& operator++()
rle_iterator& operator++() noexcept
{
operator+=(1);
return *this;
}

rle_iterator operator++(int)
rle_iterator operator++(int) noexcept
{
rle_iterator tmp = *this;
operator+=(1);
return tmp;
}

rle_iterator& operator--()
rle_iterator& operator--() noexcept
{
operator-=(1);
return *this;
}

rle_iterator operator--(int)
rle_iterator operator--(int) noexcept
{
rle_iterator tmp = *this;
operator-=(1);
return tmp;
}

rle_iterator& operator+=(difference_type move)
rle_iterator& operator+=(difference_type move) noexcept
{
// TODO: Optional iterator debug
if (move >= 0) // positive direction
{
// While we still need to move...
Expand Down Expand Up @@ -141,28 +141,25 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
return *this;
}

rle_iterator& operator-=(const difference_type offset)
rle_iterator& operator-=(const difference_type offset) noexcept
{
return *this += -offset;
return *this += -offset;
}

[[nodiscard]] rle_iterator operator+(const difference_type offset) const
[[nodiscard]] rle_iterator operator+(const difference_type offset) const noexcept
{
auto tmp = *this;
return tmp += offset;
}

[[nodiscard]] rle_iterator operator-(const difference_type offset) const
[[nodiscard]] rle_iterator operator-(const difference_type offset) const noexcept
{
auto tmp = *this;
return tmp -= offset;
}

[[nodiscard]] difference_type operator-(const rle_iterator& right) const
[[nodiscard]] difference_type operator-(const rle_iterator& right) const noexcept
{
// TODO: Optional iterator debug

// Hold the accumulation.
difference_type accumulation = 0;

Expand Down Expand Up @@ -203,7 +200,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
return accumulation;
}

[[nodiscard]] reference operator[](const difference_type offset) const
[[nodiscard]] reference operator[](const difference_type offset) const noexcept
{
return *operator+(offset);
}
Expand Down Expand Up @@ -384,7 +381,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
}
}

void swap(basic_rle& other)
void swap(basic_rle& other) noexcept
{
_runs.swap(other._runs);
std::swap(_total_length, other._total_length);
Expand Down Expand Up @@ -425,7 +422,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
return it->value;
}

[[nodiscard]] basic_rle slice(size_type start_index, size_type end_index) const
[[nodiscard]] basic_rle slice(size_type start_index, size_type end_index) const noexcept
{
if (end_index > _total_length)
{
Expand Down Expand Up @@ -460,7 +457,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
{
_check_indices(start_index, end_index);

rle_type new_run{ value, end_index - start_index };
const rle_type new_run{ value, end_index - start_index };
_replace(start_index, end_index, { &new_run, 1 });
}

Expand All @@ -479,7 +476,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"

// Replaces every value seen in the run with a new one
// Does not change the length or position of the values.
void replace_values(const value_type& old_value, const value_type& new_value) noexcept(std::is_nothrow_copy_assignable<value_type>::value)
void replace_values(const value_type& old_value, const value_type& new_value)
{
for (auto& run : _runs)
{
Expand All @@ -506,7 +503,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
rle_scanner scanner(_runs.begin(), _runs.end());
auto [run, pos] = scanner.scan(new_size - 1);

run->length = pos + 1;
run->length = ++pos;

_runs.erase(++run, _runs.cend());
}
Expand Down Expand Up @@ -709,7 +706,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"

if (start_index != 0 && end_index != _total_length)
{
auto previous = begin_pos ? begin : begin - 1;
const auto previous = begin_pos ? begin : begin - 1;
if (previous->value == end->value)
{
end->length -= end_pos - (begin_pos ? begin_pos : previous->length);
Expand Down Expand Up @@ -762,7 +759,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
size_type end_additional_length = 0;
if (start_index != 0)
{
auto previous = begin_pos ? begin : begin - 1;
const auto previous = begin_pos ? begin : begin - 1;
if (previous->value == new_runs.front().value)
{
begin_additional_length = begin_pos ? begin_pos : previous->length;
Expand Down Expand Up @@ -833,15 +830,13 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"

const auto new_runs_begin = new_runs.begin();
const auto new_runs_end = new_runs.end();
auto new_runs_it = new_runs_begin;

// First copy over as much data as can fit into the existing [start_index, end_index) range.
// Afterwards two situations can occur:
//
// * All data was copied and we have we have more space left
const auto direct_copy_end = new_runs_it + std::min(available_space, new_runs.size());
begin = std::copy(new_runs_it, direct_copy_end, begin);
new_runs_it = direct_copy_end;
const auto direct_copy_end = new_runs_begin + std::min(available_space, new_runs.size());
begin = std::copy(new_runs_begin, direct_copy_end, begin);

if (available_space >= required_space)
{
Expand All @@ -858,12 +853,12 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
if (mid_insertion_trailer)
{
_runs.insert(begin, required_space - available_space, {});
begin = std::copy(new_runs_it, new_runs_end, _runs.begin() + begin_index);
begin = std::copy(direct_copy_end, new_runs_end, _runs.begin() + begin_index);
*begin = *std::move(mid_insertion_trailer);
}
else
{
_runs.insert(begin, new_runs_it, new_runs_end);
_runs.insert(begin, direct_copy_end, new_runs_end);
}
}

Expand All @@ -883,9 +878,9 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"

_total_length -= end_index - start_index;

for (auto it = new_runs_begin; it != new_runs_end; ++it)
for (const auto& run : new_runs)
{
_total_length += it->length;
_total_length += run.length;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/til/precomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Module Name:
#define BLOCK_TIL
// This includes support libraries from the CRT, STL, WIL, and GSL
#include "LibraryIncludes.h"
#include <charconv>

#include "WexTestClass.h"

Expand Down

0 comments on commit 1822335

Please sign in to comment.