• Home
  • Raw
  • Download

Lines Matching refs:lits

36     lits: Vec<Literal>,  field
54 Literals { lits: vec![], limit_size: 250, limit_class: 10 } in empty()
59 let mut lits = Literals::empty(); in prefixes() localVariable
60 lits.union_prefixes(expr); in prefixes()
61 lits in prefixes()
66 let mut lits = Literals::empty(); in suffixes() localVariable
67 lits.union_suffixes(expr); in suffixes()
68 lits in suffixes()
110 &self.lits in literals()
118 for lit in &self.lits { in min_len()
130 !self.lits.is_empty() && self.lits.iter().all(|l| !l.is_cut()) in all_complete()
135 self.lits.iter().any(|lit| !lit.is_cut()) in any_complete()
140 self.lits.iter().any(|lit| lit.is_empty()) in contains_empty()
145 self.lits.is_empty() || self.lits.iter().all(|lit| lit.is_empty()) in is_empty()
150 let mut lits = Literals::empty(); in to_empty() localVariable
151 lits.set_limit_size(self.limit_size).set_limit_class(self.limit_class); in to_empty()
152 lits in to_empty()
160 let lit0 = &*self.lits[0]; in longest_common_prefix()
162 for lit in &self.lits[1..] { in longest_common_prefix()
168 &self.lits[0][..len] in longest_common_prefix()
176 let lit0 = &*self.lits[0]; in longest_common_suffix()
178 for lit in &self.lits[1..] { in longest_common_suffix()
188 &self.lits[0][self.lits[0].len() - len..] in longest_common_suffix()
204 for mut lit in self.lits.iter().cloned() { in trim_suffix()
208 new.lits.push(lit); in trim_suffix()
210 new.lits.sort(); in trim_suffix()
211 new.lits.dedup(); in trim_suffix()
225 if self.lits.is_empty() { in unambiguous_prefixes()
228 let mut old: Vec<Literal> = self.lits.iter().cloned().collect(); in unambiguous_prefixes()
234 if new.lits.is_empty() { in unambiguous_prefixes()
235 new.lits.push(candidate); in unambiguous_prefixes()
238 for lit2 in &mut new.lits { in unambiguous_prefixes()
274 new.lits.push(candidate); in unambiguous_prefixes()
276 new.lits.retain(|lit| !lit.is_empty()); in unambiguous_prefixes()
277 new.lits.sort(); in unambiguous_prefixes()
278 new.lits.dedup(); in unambiguous_prefixes()
293 let mut lits = self.clone(); in unambiguous_suffixes() localVariable
294 lits.reverse(); in unambiguous_suffixes()
295 let mut unamb = lits.unambiguous_prefixes(); in unambiguous_suffixes()
310 let mut lits = self.to_empty(); in union_prefixes() localVariable
311 prefixes(expr, &mut lits); in union_prefixes()
312 !lits.is_empty() && !lits.contains_empty() && self.union(lits) in union_prefixes()
325 let mut lits = self.to_empty(); in union_suffixes() localVariable
326 suffixes(expr, &mut lits); in union_suffixes()
327 lits.reverse(); in union_suffixes()
328 !lits.is_empty() && !lits.contains_empty() && self.union(lits) in union_suffixes()
336 pub fn union(&mut self, lits: Literals) -> bool { in union()
337 if self.num_bytes() + lits.num_bytes() > self.limit_size { in union()
340 if lits.is_empty() { in union()
341 self.lits.push(Literal::empty()); in union()
343 self.lits.extend(lits.lits); in union()
355 pub fn cross_product(&mut self, lits: &Literals) -> bool { in cross_product()
356 if lits.is_empty() { in cross_product()
363 for lits_lit in lits.literals() { in cross_product()
367 size_after = self.lits.iter().fold(0, |accum, lit| { in cross_product()
370 for lits_lit in lits.literals() { in cross_product()
386 for lits_lit in lits.literals() { in cross_product()
390 self.lits.push(self_lit); in cross_product()
411 if self.lits.is_empty() { in cross_add()
413 self.lits.push(Literal::new(bytes[..i].to_owned())); in cross_add()
414 self.lits[0].cut = i < bytes.len(); in cross_add()
415 return !self.lits[0].is_cut(); in cross_add()
418 if size + self.lits.len() >= self.limit_size { in cross_add()
422 while size + (i * self.lits.len()) <= self.limit_size in cross_add()
427 for lit in &mut self.lits { in cross_add()
446 self.lits.push(lit); in add()
488 self.lits.push(lit); in _add_char_class()
511 self.lits.push(lit); in add_byte_class()
521 for lit in &mut self.lits { in cut()
528 for lit in &mut self.lits { in reverse()
535 self.lits.clear(); in clear()
541 for lit in mem::replace(&mut self.lits, vec![]) { in remove_complete()
543 self.lits.push(lit); in remove_complete()
553 self.lits.iter().fold(0, |accum, lit| accum + lit.len()) in num_bytes()
566 let new_byte_count = if self.lits.is_empty() { in class_exceeds_limits()
569 self.lits.iter().fold(0, |accum, lit| { in class_exceeds_limits()
584 fn prefixes(expr: &Hir, lits: &mut Literals) { in prefixes()
588 lits.cross_add(c.encode_utf8(&mut buf).as_bytes()); in prefixes()
591 lits.cross_add(&[b]); in prefixes()
594 if !lits.add_char_class(cls) { in prefixes()
595 lits.cut(); in prefixes()
599 if !lits.add_byte_class(cls) { in prefixes()
600 lits.cut(); in prefixes()
604 prefixes(&**hir, lits); in prefixes()
608 repeat_zero_or_one_literals(&x.hir, lits, prefixes); in prefixes()
611 repeat_zero_or_more_literals(&x.hir, lits, prefixes); in prefixes()
614 repeat_one_or_more_literals(&x.hir, lits, prefixes); in prefixes()
623 &x.hir, min, max, x.greedy, lits, prefixes, in prefixes()
628 HirKind::Concat(ref es) if es.len() == 1 => prefixes(&es[0], lits), in prefixes()
632 if !lits.is_empty() { in prefixes()
633 lits.cut(); in prefixes()
636 lits.add(Literal::empty()); in prefixes()
639 let mut lits2 = lits.to_empty(); in prefixes()
641 if !lits.cross_product(&lits2) || !lits2.any_complete() { in prefixes()
645 lits.cut(); in prefixes()
651 alternate_literals(es, lits, prefixes); in prefixes()
653 _ => lits.cut(), in prefixes()
657 fn suffixes(expr: &Hir, lits: &mut Literals) { in suffixes()
664 lits.cross_add(buf); in suffixes()
667 lits.cross_add(&[b]); in suffixes()
670 if !lits.add_char_class_reverse(cls) { in suffixes()
671 lits.cut(); in suffixes()
675 if !lits.add_byte_class(cls) { in suffixes()
676 lits.cut(); in suffixes()
680 suffixes(&**hir, lits); in suffixes()
684 repeat_zero_or_one_literals(&x.hir, lits, suffixes); in suffixes()
687 repeat_zero_or_more_literals(&x.hir, lits, suffixes); in suffixes()
690 repeat_one_or_more_literals(&x.hir, lits, suffixes); in suffixes()
699 &x.hir, min, max, x.greedy, lits, suffixes, in suffixes()
704 HirKind::Concat(ref es) if es.len() == 1 => suffixes(&es[0], lits), in suffixes()
708 if !lits.is_empty() { in suffixes()
709 lits.cut(); in suffixes()
712 lits.add(Literal::empty()); in suffixes()
715 let mut lits2 = lits.to_empty(); in suffixes()
717 if !lits.cross_product(&lits2) || !lits2.any_complete() { in suffixes()
721 lits.cut(); in suffixes()
727 alternate_literals(es, lits, suffixes); in suffixes()
729 _ => lits.cut(), in suffixes()
735 lits: &mut Literals, in repeat_zero_or_one_literals()
738 let (mut lits2, mut lits3) = (lits.clone(), lits.to_empty()); in repeat_zero_or_one_literals()
739 lits3.set_limit_size(lits.limit_size() / 2); in repeat_zero_or_one_literals()
743 lits.cut(); in repeat_zero_or_one_literals()
747 if !lits.union(lits2) { in repeat_zero_or_one_literals()
748 lits.cut(); in repeat_zero_or_one_literals()
754 lits: &mut Literals, in repeat_zero_or_more_literals()
757 let (mut lits2, mut lits3) = (lits.clone(), lits.to_empty()); in repeat_zero_or_more_literals()
758 lits3.set_limit_size(lits.limit_size() / 2); in repeat_zero_or_more_literals()
762 lits.cut(); in repeat_zero_or_more_literals()
767 if !lits.union(lits2) { in repeat_zero_or_more_literals()
768 lits.cut(); in repeat_zero_or_more_literals()
774 lits: &mut Literals, in repeat_one_or_more_literals()
777 f(e, lits); in repeat_one_or_more_literals()
778 lits.cut(); in repeat_one_or_more_literals()
786 lits: &mut Literals, in repeat_range_literals()
799 lits, in repeat_range_literals()
803 let n = cmp::min(lits.limit_size, min as usize); in repeat_range_literals()
805 f(&Hir::concat(es), lits); in repeat_range_literals()
806 if n < min as usize || lits.contains_empty() { in repeat_range_literals()
807 lits.cut(); in repeat_range_literals()
811 lits.cut(); in repeat_range_literals()
818 lits: &mut Literals, in alternate_literals()
821 let mut lits2 = lits.to_empty(); in alternate_literals()
823 let mut lits3 = lits.to_empty(); in alternate_literals()
824 lits3.set_limit_size(lits.limit_size() / 5); in alternate_literals()
831 lits.cut(); in alternate_literals()
835 if !lits.cross_product(&lits2) { in alternate_literals()
836 lits.cut(); in alternate_literals()
843 .field("lits", &self.lits) in fmt()
1000 lits: it.into_iter().collect(), in create_lits()
1050 fn prefixes(lits: &mut Literals, expr: &Hir) { in prefixes()
1051 lits.union_prefixes(expr); in prefixes()
1054 fn suffixes(lits: &mut Literals, expr: &Hir) { in suffixes()
1055 lits.union_suffixes(expr); in suffixes()
1061 let lits = $got_lits; localVariable
1064 $which(escape_lits(lits.literals())));
1067 lits.all_complete());
1070 lits.any_complete());
1085 let lits = Literals::$which(&expr); localVariable
1086 assert_lit_eq!(Unicode, lits, $($lit),*);
1094 let lits = Literals::$which(&expr); localVariable
1095 assert_lit_eq!(Bytes, lits, $($lit),*);
1273 let mut lits = Literals::empty(); localVariable
1274 lits.set_limit_size(20).set_limit_class(10);
1275 $which(&mut lits, &expr);
1276 assert_lit_eq!(Unicode, lits, $($lit),*);
1284 let mut lits = Literals::empty(); localVariable
1285 lits.set_limit_size(20).set_limit_class(10);
1286 $which(&mut lits, &expr);
1287 assert_lit_eq!(Bytes, lits, $($lit),*);
1535 let lits = create_lits(given); localVariable
1536 let got = lits.unambiguous_prefixes();
1604 let lits = create_lits(given); localVariable
1605 let got = lits.trim_suffix($trim).unwrap();
1631 let lits = create_lits(given); localVariable
1632 let got = lits.longest_common_prefix();
1666 let lits = create_lits(given); localVariable
1667 let got = lits.longest_common_suffix();