From 904ac01a1cc692669c0a5a3e533b1b8b87b056f9 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 7 Jan 2017 16:22:42 -0500 Subject: [PATCH] record the parent ID of each change operation --- src/core/Buffer.cc | 9 +++++---- src/core/Buffer.h | 2 +- src/core/ChangeOperation.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/Buffer.cc b/src/core/Buffer.cc index 7244cb3..0d17d47 100644 --- a/src/core/Buffer.cc +++ b/src/core/Buffer.cc @@ -40,7 +40,7 @@ void Buffer::common_initialization() } m_change_buffer = std::make_shared(); 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(); + 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; } } diff --git a/src/core/Buffer.h b/src/core/Buffer.h index 36e806a..abee5a2 100644 --- a/src/core/Buffer.h +++ b/src/core/Buffer.h @@ -141,7 +141,7 @@ protected: std::string m_filename; std::shared_ptr m_current_change_operation; int m_operation_level; - size_t m_current_operation_index; + size_t m_current_change_operation_index; std::vector> m_change_operations; void common_initialization(); diff --git a/src/core/ChangeOperation.h b/src/core/ChangeOperation.h index a177b20..6aee442 100644 --- a/src/core/ChangeOperation.h +++ b/src/core/ChangeOperation.h @@ -8,6 +8,7 @@ class ChangeOperation { public: + size_t parent; std::list changes; std::list children; };