From d511cdd58882e93fbc5e4e59d336ed99a9a0686d Mon Sep 17 00:00:00 2001 From: Boaz Yaniv Date: Mon, 21 Oct 2024 17:27:40 +0900 Subject: [PATCH] Combine two matche clauses --- src/lib.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4a9b0f5..17d7b43 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -376,9 +376,18 @@ impl Parser { // APC Actions are checked last, since they are relatively rare. Action::OpaqueStart => { let kind = match byte { - 0x58 => OpaqueSequenceKind::Sos, - 0x5e => OpaqueSequenceKind::Pm, - 0x5f => OpaqueSequenceKind::Apc, + 0x58 => { + performer.sos_start(); + OpaqueSequenceKind::Sos + }, + 0x5e => { + performer.pm_start(); + OpaqueSequenceKind::Pm + }, + 0x5f => { + performer.apc_start(); + OpaqueSequenceKind::Apc + }, // Changes to OpaqueString state which trigger this action are only possible // when one of the escape sequences above is detected (see Escape state changes @@ -387,11 +396,6 @@ impl Parser { _ => unreachable!("invalid opaque sequence kind"), }; self.opaque_sequence_kind = Some(kind); - match kind { - OpaqueSequenceKind::Sos => performer.sos_start(), - OpaqueSequenceKind::Pm => performer.pm_start(), - OpaqueSequenceKind::Apc => performer.apc_start(), - } }, Action::OpaquePut => { match self.opaque_sequence_kind { @@ -961,7 +965,7 @@ mod tests { assert_eq!(dispatcher.dispatched.len(), 1); match &dispatcher.dispatched[0] { - Sequence::Csi(params, ..) => assert_eq!(params, &[[std::u16::MAX as u16]]), + Sequence::Csi(params, ..) => assert_eq!(params, &[[std::u16::MAX]]), _ => panic!("expected csi sequence"), } }