Show More
@@ -737,14 +737,11 b' impl RegexMatcher {' | |||
|
737 | 737 | } |
|
738 | 738 | } |
|
739 | 739 | |
|
740 | /// Returns a function that matches an `HgPath` against the given regex | |
|
741 | /// pattern. | |
|
740 | /// Return a `RegexBuilder` from a bytes pattern | |
|
742 | 741 | /// |
|
743 | /// This can fail when the pattern is invalid or not supported by the | |
|
744 | /// underlying engine (the `regex` crate), for instance anything with | |
|
745 | /// back-references. | |
|
746 | #[logging_timer::time("trace")] | |
|
747 | fn re_matcher(pattern: &[u8]) -> PatternResult<RegexMatcher> { | |
|
742 | /// This works around the fact that even if it works on byte haysacks, | |
|
743 | /// [`regex::bytes::Regex`] still uses UTF-8 patterns. | |
|
744 | pub fn re_bytes_builder(pattern: &[u8]) -> regex::bytes::RegexBuilder { | |
|
748 | 745 | use std::io::Write; |
|
749 | 746 | |
|
750 | 747 | // The `regex` crate adds `.*` to the start and end of expressions if there |
@@ -764,7 +761,18 b' fn re_matcher(pattern: &[u8]) -> Pattern' | |||
|
764 | 761 | // # Safety |
|
765 | 762 | // This is safe because we escaped all non-ASCII bytes. |
|
766 | 763 | let pattern_string = unsafe { String::from_utf8_unchecked(escaped_bytes) }; |
|
767 |
|
|
|
764 | regex::bytes::RegexBuilder::new(&pattern_string) | |
|
765 | } | |
|
766 | ||
|
767 | /// Returns a function that matches an `HgPath` against the given regex | |
|
768 | /// pattern. | |
|
769 | /// | |
|
770 | /// This can fail when the pattern is invalid or not supported by the | |
|
771 | /// underlying engine (the `regex` crate), for instance anything with | |
|
772 | /// back-references. | |
|
773 | #[logging_timer::time("trace")] | |
|
774 | fn re_matcher(pattern: &[u8]) -> PatternResult<RegexMatcher> { | |
|
775 | let re = re_bytes_builder(pattern) | |
|
768 | 776 | .unicode(false) |
|
769 | 777 | // Big repos with big `.hgignore` will hit the default limit and |
|
770 | 778 | // incur a significant performance hit. One repo's `hg status` hit |
General Comments 0
You need to be logged in to leave comments.
Login now