Skip to content

Commit

Permalink
chore: enable the fast-regexp feature
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Sep 6, 2023
1 parent 7641544 commit 611a479
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions yara-x/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,17 +1154,11 @@ impl<'a> Compiler<'a> {
hir: &re::hir::Hir,
span: Span,
) -> Result<(Vec<re::RegexpAtom>, bool), CompileError> {
//#[cfg(not(feature = "fast-regexp"))]
//let (result, is_fast_regexp) = (
//re::thompson::Compiler::new().compile(hir, &mut self.re_code),
// false,
//);

// When the `fast-regexp` feature is enabled, try to compile the regexp
// for `FastVM` first, if the it fails with `Error::FastIncompatible`,
// the regexp is not compatible for `FastVM` and `PikeVM` must be used
// instead.
//#[cfg(feature = "fast-regexp")]
#[cfg(feature = "fast-regexp")]
let (result, is_fast_regexp) = match re::fast::Compiler::new()
.compile(hir, &mut self.re_code)
{
Expand All @@ -1175,6 +1169,12 @@ impl<'a> Compiler<'a> {
result => (result, true),
};

#[cfg(not(feature = "fast-regexp"))]
let (result, is_fast_regexp) = (
re::thompson::Compiler::new().compile(hir, &mut self.re_code),
false,
);

let atoms = result.map_err(|err| match err {
re::Error::TooLarge => {
CompileError::from(CompileErrorInfo::invalid_regexp(
Expand Down

0 comments on commit 611a479

Please sign in to comment.