Optimised container move for external buffers

This commit is contained in:
John Wellbelove 2022-07-24 13:01:07 +01:00
parent b2e1c35540
commit df01759227
3 changed files with 20 additions and 30 deletions

7
.gitignore vendored
View File

@ -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

View File

@ -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<T>::iterator first = rhs.begin();
etl::iforward_list<T>::iterator last = rhs.end();
etl::iforward_list<T>::iterator last = rhs.end();
while (first != last)
{

View File

@ -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);
}