From df017592277f0d52f0697fc8a33c3ccfd56cd9fe Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 24 Jul 2022 13:01:07 +0100 Subject: [PATCH] Optimised container move for external buffers --- .gitignore | 7 +++++++ include/etl/forward_list.h | 23 +++++++---------------- include/etl/list.h | 20 ++++++-------------- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 50091462..124c39b0 100644 --- a/.gitignore +++ b/.gitignore @@ -363,3 +363,10 @@ test/etl_initializer_list/etl_initializer_list.vcxproj.filters test/etl_initializer_list/build-make test/vs-build test/etl_error_handler/build-log_errors-GCC-Debug +test/etl_error_handler/build-exceptions_and_log_errors-GCC-Debug +test/etl_error_handler/build-exceptions-GCC-Debug +test/etl_error_handler/exceptions_and_log_errors/.vs +test/etl_error_handler/exceptions/build-make +test/etl_error_handler/log_errors/build-make +test/etl_error_handler/log_errors_and_exceptions/build-make +test/etl_error_handler/log_errors_and_exceptions/.vs diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 7f8d03a9..b33cb029 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -1485,34 +1485,25 @@ namespace etl if (!rhs.empty()) { - node_t* p_last_node = &this->start_node; - node_t* p_rhs_node = rhs.start_node.next; - // Are we using the same pool? if (this->get_node_pool() == rhs.get_node_pool()) { - // Just link the nodes to the new forward_list. - do - { - node_t* p_node = p_rhs_node; - p_rhs_node = p_rhs_node->next; + // Just link the nodes to this list. + this->start_node.next = rhs.start_node.next; - insert_node_after(*p_last_node, *p_node); - - p_last_node = p_node; - - ETL_INCREMENT_DEBUG_COUNT; - - } while (p_rhs_node != ETL_NULLPTR); + ETL_SET_DEBUG_COUNT(ETL_OBJECT_GET_DEBUG_COUNT(rhs)); ETL_OBJECT_RESET_DEBUG_COUNT(rhs); rhs.start_node.next = ETL_NULLPTR; } else { + node_t* p_last_node = &this->start_node; + node_t* p_rhs_node = rhs.start_node.next; + // Add all of the elements. etl::iforward_list::iterator first = rhs.begin(); - etl::iforward_list::iterator last = rhs.end(); + etl::iforward_list::iterator last = rhs.end(); while (first != last) { diff --git a/include/etl/list.h b/include/etl/list.h index 82c15709..c6a52561 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -1824,7 +1824,7 @@ namespace etl #if ETL_USING_CPP11 //************************************************************************* - /// Move a forward list + /// Move a list //************************************************************************* void move_container(ilist&& rhs) { @@ -1837,21 +1837,13 @@ namespace etl // Are we using the same pool? if (this->get_node_pool() == rhs.get_node_pool()) { - node_t* p_rhs_node = &rhs.get_head(); + // Just link the nodes to this list. + join(terminal_node, rhs.get_head()); + join(rhs.get_tail(), terminal_node); - // Just link the nodes to the new forward_list. - do - { - ETL_ASSERT(!full(), ETL_ERROR(list_full)); - - node_t* p_node = p_rhs_node; - p_rhs_node = p_rhs_node->next; - insert_node(terminal_node, *p_node); - - ETL_INCREMENT_DEBUG_COUNT; - - } while (p_rhs_node != &rhs.terminal_node); + ETL_SET_DEBUG_COUNT(ETL_OBJECT_GET_DEBUG_COUNT(rhs)); + // Clear the rhs. ETL_OBJECT_RESET_DEBUG_COUNT(rhs); rhs.join(rhs.terminal_node, rhs.terminal_node); }