Skip to content

Commit

Permalink
refactor: Use of match statement instead of if-else
Browse files Browse the repository at this point in the history
  • Loading branch information
IshanGrover2004 committed May 21, 2024
1 parent 37c74f2 commit b8a7fd6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/rust/src/decoder/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ pub extern "C" fn dtvcc_get_internal_from_G1(g1_char: u8) -> u8 {
/// G2: Extended Control Code Set 1
#[no_mangle]
pub extern "C" fn dtvcc_get_internal_from_G2(g2_char: u8) -> u8 {
if (0x20..=0x3F).contains(&g2_char) {
g2_char - 0x20
} else if (0x60..=0x7F).contains(&g2_char) {
g2_char + 0x20
} else {
// Rest unmapped, so we return a blank space
0x20
match g2_char {
0x20..=0x3F => g2_char - 0x20,
0x60..=0x7F => g2_char + 0x20,
_ => 0x20,
}
}

Expand Down

0 comments on commit b8a7fd6

Please sign in to comment.