From 920243b12d561aa3abb6ca96cd8a985468d24564 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 23 Oct 2019 07:29:02 +0200 Subject: [PATCH] pxar: simplify MatchPattern::to_bytes --- src/pxar/match_pattern.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/pxar/match_pattern.rs b/src/pxar/match_pattern.rs index 7a7ef75d..a6c22d1c 100644 --- a/src/pxar/match_pattern.rs +++ b/src/pxar/match_pattern.rs @@ -222,23 +222,9 @@ impl MatchPattern { pub fn to_bytes(patterns: &[MatchPattern]) -> Vec { let mut buffer = Vec::new(); for pattern in patterns { - let byte_pattern = pattern.pattern.as_bytes(); - match (pattern.match_positive, pattern.match_dir_only) { - (true, true) => { - buffer.extend_from_slice(byte_pattern); - buffer.push(b'/'); - } - (true, false) => buffer.extend_from_slice(byte_pattern), - (false, true) => { - buffer.push(b'!'); - buffer.extend_from_slice(byte_pattern); - buffer.push(b'/'); - } - (false, false) => { - buffer.push(b'!'); - buffer.extend_from_slice(byte_pattern); - } - } + if !pattern.match_positive { buffer.push(b'!'); } + buffer.extend_from_slice( pattern.pattern.as_bytes()); + if pattern.match_dir_only { buffer.push(b'/'); } buffer.push(b'\n'); } buffer