record the parent ID of each change operation

This commit is contained in:
Josh Holtrop 2017-01-07 16:22:42 -05:00
parent 5f37229c19
commit 904ac01a1c
3 changed files with 7 additions and 5 deletions

View File

@ -40,7 +40,7 @@ void Buffer::common_initialization()
}
m_change_buffer = std::make_shared<GapBuffer>();
m_operation_level = 0;
m_current_operation_index = 0u;
m_current_change_operation_index = 0xFFFFFFFFu;
}
void Buffer::load_empty_buffer()
@ -240,6 +240,7 @@ void Buffer::record_change(uint8_t data[], size_t length, size_t buffer_position
if (!m_current_change_operation)
{
m_current_change_operation = std::make_shared<ChangeOperation>();
m_current_change_operation->parent = m_current_change_operation_index;
}
if (m_current_change_operation->changes.size() > 0)
{
@ -309,12 +310,12 @@ void Buffer::save_current_operation()
if (m_current_change_operation)
{
size_t new_change_operation_index = m_change_operations.size();
if (m_current_operation_index < new_change_operation_index)
if (m_current_change_operation_index < new_change_operation_index)
{
m_change_operations[m_current_operation_index]->children.push_back(new_change_operation_index);
m_change_operations[m_current_change_operation_index]->children.push_back(new_change_operation_index);
}
m_change_operations.push_back(m_current_change_operation);
m_current_change_operation = nullptr;
m_current_operation_index = new_change_operation_index;
m_current_change_operation_index = new_change_operation_index;
}
}

View File

@ -141,7 +141,7 @@ protected:
std::string m_filename;
std::shared_ptr<ChangeOperation> m_current_change_operation;
int m_operation_level;
size_t m_current_operation_index;
size_t m_current_change_operation_index;
std::vector<std::shared_ptr<ChangeOperation>> m_change_operations;
void common_initialization();

View File

@ -8,6 +8,7 @@
class ChangeOperation
{
public:
size_t parent;
std::list<ChangeUnit> changes;
std::list<size_t> children;
};