Reduce HealthCache heap use (#785)

Growing these vectors is a waste, rough measurements say this saves
around 1k bytes for a 5 tokens and 4 serum account.
This commit is contained in:
Christian Kamm 2023-11-20 10:15:39 +01:00 committed by GitHub
parent 0ac930eb8d
commit 57a9835aa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1251,7 +1251,7 @@ fn new_health_cache_impl(
skip_bad_oracles: bool,
) -> Result<HealthCache> {
// token contribution from token accounts
let mut token_infos = vec![];
let mut token_infos = Vec::with_capacity(account.active_token_positions().count());
for (i, position) in account.active_token_positions().enumerate() {
let bank_oracle_result =
@ -1290,7 +1290,7 @@ fn new_health_cache_impl(
}
// Fill the TokenInfo balance with free funds in serum3 oo accounts and build Serum3Infos.
let mut serum3_infos = vec![];
let mut serum3_infos = Vec::with_capacity(account.active_serum3_orders().count());
for (i, serum_account) in account.active_serum3_orders().enumerate() {
let oo = retriever.serum_oo(i, &serum_account.open_orders)?;