From 8fd170cbcc6f97571e542ce4fe0d5362ba822a92 Mon Sep 17 00:00:00 2001 From: Honglu Lei Date: Fri, 22 Feb 2019 11:13:00 +0800 Subject: [PATCH] change undo stack processing order to created-modified-removed --- include/chainbase/chainbase.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/chainbase/chainbase.hpp b/include/chainbase/chainbase.hpp index 7ce93bc..25f675e 100644 --- a/include/chainbase/chainbase.hpp +++ b/include/chainbase/chainbase.hpp @@ -318,6 +318,12 @@ namespace chainbase { const auto& head = _stack.back(); + for( auto id : head.new_ids ) + { + _indices.erase( _indices.find( id ) ); + } + _next_id = head.old_next_id; + for( auto& item : head.old_values ) { auto ok = _indices.modify( _indices.find( item.second.id ), [&]( value_type& v ) { v = std::move( item.second ); @@ -325,12 +331,6 @@ namespace chainbase { if( !ok ) BOOST_THROW_EXCEPTION( std::logic_error( "Could not modify object, most likely a uniqueness constraint was violated" ) ); } - for( auto id : head.new_ids ) - { - _indices.erase( _indices.find( id ) ); - } - _next_id = head.old_next_id; - for( auto& item : head.removed_values ) { bool ok = _indices.emplace( std::move( item.second ) ).second; if( !ok ) BOOST_THROW_EXCEPTION( std::logic_error( "Could not restore object, most likely a uniqueness constraint was violated" ) );