From c4389a66758798fefa8bfe3bfda3328b51c81786 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Thu, 16 Dec 2021 23:25:22 -0600 Subject: [PATCH] AcctIdx: held ranges search in lifo order (#21964) --- runtime/src/in_mem_accounts_index.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index e3e6fbef20..6af671cc45 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -654,7 +654,8 @@ impl InMemAccountsIndex { ranges.push(inclusive_range); } else { // find the matching range and delete it since we don't want to hold it anymore - for (i, r) in ranges.iter().enumerate() { + // search backwards, assuming LIFO ordering + for (i, r) in ranges.iter().enumerate().rev() { if let (Bound::Included(start_found), Bound::Included(end_found)) = (r.start_bound(), r.end_bound()) {