reorganize check_invariant in SelectionList
This commit is contained in:
parent
7f8d5c1fd0
commit
557acc5068
|
@ -21,11 +21,16 @@ DynamicSelectionList& DynamicSelectionList::operator=(SelectionList selections)
|
|||
void DynamicSelectionList::check_invariant() const
|
||||
{
|
||||
#ifdef KAK_DEBUG
|
||||
if (empty())
|
||||
return;
|
||||
const Buffer* buf = &buffer();
|
||||
kak_assert(&front().buffer() == buf);
|
||||
SelectionList::check_invariant();
|
||||
const Buffer& buffer = registry();
|
||||
for (size_t i = 0; i < size(); ++i)
|
||||
{
|
||||
auto& sel = (*this)[i];
|
||||
kak_assert(buffer.is_valid(sel.first()));
|
||||
kak_assert(buffer.is_valid(sel.last()));
|
||||
kak_assert(utf8::is_character_start(sel.first()));
|
||||
kak_assert(utf8::is_character_start(sel.last()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -14,16 +14,6 @@ void Range::merge_with(const Range& range)
|
|||
m_first = std::max(m_first, range.m_first);
|
||||
}
|
||||
|
||||
void Range::check_invariant() const
|
||||
{
|
||||
#ifdef KAK_DEBUG
|
||||
kak_assert(m_first.is_valid() and not m_first.is_end());
|
||||
kak_assert(m_last.is_valid() and not m_last.is_end());
|
||||
kak_assert(utf8::is_character_start(m_first));
|
||||
kak_assert(utf8::is_character_start(m_last));
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
@ -116,15 +106,8 @@ void SelectionList::update_erase(const BufferCoord& begin, const BufferCoord& en
|
|||
|
||||
void SelectionList::check_invariant() const
|
||||
{
|
||||
#ifdef KAK_DEBUG
|
||||
for (size_t i = 0; i < size(); ++i)
|
||||
{
|
||||
auto& sel = (*this)[i];
|
||||
sel.check_invariant();
|
||||
if (i+1 < size())
|
||||
kak_assert(sel.min() <= (*this)[i+1].min());
|
||||
}
|
||||
#endif
|
||||
for (size_t i = 0; i+1 < size(); ++ i)
|
||||
kak_assert((*this)[i].min() <= (*this)[i+1].min());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ public:
|
|||
const BufferIterator& min() const { return std::min(m_first, m_last); }
|
||||
const BufferIterator& max() const { return std::max(m_first, m_last); }
|
||||
|
||||
|
||||
void check_invariant() const;
|
||||
private:
|
||||
BufferIterator m_first;
|
||||
BufferIterator m_last;
|
||||
|
|
Loading…
Reference in New Issue
Block a user