From d541f827bdbd8f4c43adacf00a0998a75ee998dd Mon Sep 17 00:00:00 2001 From: abitmore Date: Tue, 10 Nov 2020 05:32:05 -0500 Subject: [PATCH] Remove redundant size counting --- libraries/app/database_api.cpp | 10 +++------- libraries/app/database_api_impl.hxx | 3 +-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 557cda14f9..c87f7f9ac7 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1777,8 +1777,7 @@ vector database_api_impl::list_liquidity_pools( auto upper_itr = idx.end(); results.reserve( limit ); - uint32_t count = 0; - for ( ; lower_itr != upper_itr && count < limit; ++lower_itr, ++count) + for ( ; lower_itr != upper_itr && results.size() < limit; ++lower_itr ) { results.emplace_back( extend_liquidity_pool( *lower_itr, with_stats ) ); } @@ -1884,8 +1883,7 @@ vector database_api_impl::get_liquidity_pools_by auto upper_itr = idx.upper_bound( std::make_tuple( asset_id_a, asset_id_b ) ); results.reserve( limit ); - uint32_t count = 0; - for ( ; lower_itr != upper_itr && count < limit; ++lower_itr, ++count) + for ( ; lower_itr != upper_itr && results.size() < limit; ++lower_itr ) { results.emplace_back( extend_liquidity_pool( *lower_itr, with_stats ) ); } @@ -2025,14 +2023,12 @@ vector database_api_impl::get_liquidity_pools_by auto upper_itr = idx.upper_bound( owner ); results.reserve( limit ); - uint32_t count = 0; - for ( ; lower_itr != upper_itr && count < limit; ++lower_itr ) + for ( ; lower_itr != upper_itr && results.size() < limit; ++lower_itr ) { const asset_object& asset_obj = *lower_itr; if( !asset_obj.is_liquidity_pool_share_asset() ) // TODO improve performance continue; results.emplace_back( extend_liquidity_pool( (*asset_obj.for_liquidity_pool)(_db), with_stats ) ); - ++count; } return results; diff --git a/libraries/app/database_api_impl.hxx b/libraries/app/database_api_impl.hxx index 3660057c70..d6d8dd12ed 100644 --- a/libraries/app/database_api_impl.hxx +++ b/libraries/app/database_api_impl.hxx @@ -331,8 +331,7 @@ class database_api_impl : public std::enable_shared_from_this auto upper_itr = idx.upper_bound( asset_id ); results.reserve( limit ); - uint32_t count = 0; - for ( ; lower_itr != upper_itr && count < limit; ++lower_itr, ++count) + for ( ; lower_itr != upper_itr && results.size() < limit; ++lower_itr ) { results.emplace_back( extend_liquidity_pool( *lower_itr, with_stats ) ); }