Skip to content

Commit 9b4e695

Browse files
authored
Revert "entrypoint: remove unnecessary deser case (#233)"
This reverts commit 8935d5d.
1 parent aedc379 commit 9b4e695

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
@@ -353,31 +353,35 @@ pub unsafe fn deserialize<const MAX_ACCOUNTS: usize>(
353353
// This is an optimization to reduce the number of jumps required to process the
354354
// accounts. The macro `process_accounts` will generate inline code to process the
355355
// specified number of accounts.
356-
while to_process_plus_one > 5 {
357-
// Process 5 accounts at a time.
358-
process_accounts!(5 => (input, accounts, accounts_slice));
359-
to_process_plus_one -= 5;
360-
}
361-
362-
// There might be remaining accounts to process.
363-
match to_process_plus_one {
364-
5 => {
365-
process_accounts!(4 => (input, accounts, accounts_slice));
366-
}
367-
4 => {
368-
process_accounts!(3 => (input, accounts, accounts_slice));
369-
}
370-
3 => {
371-
process_accounts!(2 => (input, accounts, accounts_slice));
372-
}
373-
2 => {
374-
process_accounts!(1 => (input, accounts, accounts_slice));
356+
if to_process_plus_one == 2 {
357+
process_accounts!(1 => (input, accounts, accounts_slice));
358+
} else {
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;
375363
}
376-
1 => (),
377-
_ => {
378-
// SAFETY: `while` loop above makes sure that `to_process_plus_one`
379-
// has 1 to 5 entries left.
380-
unsafe { core::hint::unreachable_unchecked() }
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));
378+
}
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() }
384+
}
381385
}
382386
}
383387

0 commit comments

Comments
 (0)