Skip to content

Commit 92a5b37

Browse files
authored
Revert "entrypoint: remove unnecessary deser case" (#244)
Revert "entrypoint: remove unnecessary deser case (#233)" This reverts commit 8935d5d.
1 parent fcbe528 commit 92a5b37

File tree

1 file changed

+28
-24
lines changed
  • sdk/pinocchio/src/entrypoint

1 file changed

+28
-24
lines changed

sdk/pinocchio/src/entrypoint/mod.rs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -356,31 +356,35 @@ pub unsafe fn deserialize<const MAX_ACCOUNTS: usize>(
356356
// This is an optimization to reduce the number of jumps required to process the
357357
// accounts. The macro `process_accounts` will generate inline code to process the
358358
// specified number of accounts.
359-
while to_process_plus_one > 5 {
360-
// Process 5 accounts at a time.
361-
process_accounts!(5 => (input, accounts, accounts_slice));
362-
to_process_plus_one -= 5;
363-
}
364-
365-
// There might be remaining accounts to process.
366-
match to_process_plus_one {
367-
5 => {
368-
process_accounts!(4 => (input, accounts, accounts_slice));
369-
}
370-
4 => {
371-
process_accounts!(3 => (input, accounts, accounts_slice));
372-
}
373-
3 => {
374-
process_accounts!(2 => (input, accounts, accounts_slice));
375-
}
376-
2 => {
377-
process_accounts!(1 => (input, accounts, accounts_slice));
359+
if to_process_plus_one == 2 {
360+
process_accounts!(1 => (input, accounts, accounts_slice));
361+
} else {
362+
while to_process_plus_one > 5 {
363+
// Process 5 accounts at a time.
364+
process_accounts!(5 => (input, accounts, accounts_slice));
365+
to_process_plus_one -= 5;
378366
}
379-
1 => (),
380-
_ => {
381-
// SAFETY: `while` loop above makes sure that `to_process_plus_one`
382-
// has 1 to 5 entries left.
383-
unsafe { core::hint::unreachable_unchecked() }
367+
368+
// There might be remaining accounts to process.
369+
match to_process_plus_one {
370+
5 => {
371+
process_accounts!(4 => (input, accounts, accounts_slice));
372+
}
373+
4 => {
374+
process_accounts!(3 => (input, accounts, accounts_slice));
375+
}
376+
3 => {
377+
process_accounts!(2 => (input, accounts, accounts_slice));
378+
}
379+
2 => {
380+
process_accounts!(1 => (input, accounts, accounts_slice));
381+
}
382+
1 => (),
383+
_ => {
384+
// SAFETY: `while` loop above makes sure that `to_process_plus_one`
385+
// has 1 to 5 entries left.
386+
unsafe { core::hint::unreachable_unchecked() }
387+
}
384388
}
385389
}
386390

0 commit comments

Comments
 (0)