Comments
Patch
@@ -37,6 +37,10 @@
}
}
+pub fn concat(slices: &[&[u8]]) -> Vec<u8> {
+ slices.concat()
+}
+
pub trait SliceExt {
fn trim_end(&self) -> &Self;
fn trim_start(&self) -> &Self;
@@ -8,7 +8,7 @@
//! Handling of Mercurial-specific patterns.
use crate::{
- utils::{files::get_path_from_bytes, SliceExt},
+ utils::{concat, files::get_path_from_bytes, SliceExt},
LineNumber, PatternError, PatternFileError,
};
use lazy_static::lazy_static;
@@ -158,20 +158,20 @@
if pattern[0] == b'^' {
return pattern.to_owned();
}
- [&b".*"[..], pattern].concat()
+ concat(&[b".*", pattern])
}
PatternSyntax::Path | PatternSyntax::RelPath => {
if pattern == b"." {
return vec![];
}
- [&escape_pattern(pattern), &b"(?:/|$)"[..]].concat()
+ concat(&[&escape_pattern(pattern), b"(?:/|$)"])
}
PatternSyntax::RootFiles => {
let mut res = if pattern == b"." {
vec![]
} else {
// Pattern is a directory name.
- [&escape_pattern(pattern), &b"/"[..]].concat()
+ concat(&[&escape_pattern(pattern), b"/"])
};
// Anything after the pattern must be a non-directory.
@@ -181,14 +181,14 @@
PatternSyntax::RelGlob => {
let glob_re = glob_to_re(pattern);
if let Some(rest) = glob_re.drop_prefix(b"[^/]*") {
- [&b".*"[..], rest, globsuffix].concat()
+ concat(&[b".*", rest, globsuffix])
} else {
- [&b"(?:|.*/)"[..], &glob_re, globsuffix].concat()
+ concat(&[b"(?:|.*/)", &glob_re, globsuffix])
}
}
PatternSyntax::Glob
| PatternSyntax::RootGlob => {
- [&glob_to_re(pattern), globsuffix].concat()
+ concat(&[&glob_to_re(pattern), globsuffix])
}
}
}