Skip to content

Commit

Permalink
Remove redundant size counting
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Nov 10, 2020
1 parent 144be48 commit d541f82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 3 additions & 7 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,8 +1777,7 @@ vector<extended_liquidity_pool_object> 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 ) );
}
Expand Down Expand Up @@ -1884,8 +1883,7 @@ vector<extended_liquidity_pool_object> 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 ) );
}
Expand Down Expand Up @@ -2025,14 +2023,12 @@ vector<extended_liquidity_pool_object> 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;
Expand Down
3 changes: 1 addition & 2 deletions libraries/app/database_api_impl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
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 ) );
}
Expand Down

0 comments on commit d541f82

Please sign in to comment.