(&mut self, seq: I)
| 888 | } |
| 889 | |
| 890 | fn c_utf8_seq_<'r, I>(&mut self, seq: I) -> Result |
| 891 | where I: IntoIterator<Item=&'r Utf8Range> { |
| 892 | // The initial instruction for each UTF-8 sequence should be the same. |
| 893 | let mut from_inst = ::std::usize::MAX; |
| 894 | let mut last_hole = Hole::None; |
| 895 | for byte_range in seq { |
| 896 | let key = SuffixCacheKey { |
| 897 | from_inst: from_inst, |
| 898 | start: byte_range.start, |
| 899 | end: byte_range.end, |
| 900 | }; |
| 901 | { |
| 902 | let pc = self.c.insts.len(); |
| 903 | if let Some(cached_pc) = self.c.suffix_cache.get(key, pc) { |
| 904 | from_inst = cached_pc; |
| 905 | continue; |
| 906 | } |
| 907 | } |
| 908 | self.c.byte_classes.set_range(byte_range.start, byte_range.end); |
| 909 | if from_inst == ::std::usize::MAX { |
| 910 | last_hole = self.c.push_hole(InstHole::Bytes { |
| 911 | start: byte_range.start, |
| 912 | end: byte_range.end, |
| 913 | }); |
| 914 | } else { |
| 915 | self.c.push_compiled(Inst::Bytes(InstBytes { |
| 916 | goto: from_inst, |
| 917 | start: byte_range.start, |
| 918 | end: byte_range.end, |
| 919 | })); |
| 920 | } |
| 921 | from_inst = self.c.insts.len().checked_sub(1).unwrap(); |
| 922 | debug_assert!(from_inst < ::std::usize::MAX); |
| 923 | } |
| 924 | debug_assert!(from_inst < ::std::usize::MAX); |
| 925 | Ok(Patch { hole: last_hole, entry: from_inst }) |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | /// `SuffixCache` is a simple bounded hash map for caching suffix entries in |
no test coverage detected