Skip to content

Very large copies in compiled regexes. #86

Closed
@eddyb

Description

@eddyb

There is a ::std::mem::swap(&mut clist, &mut nlist); call generated when using regex!.
The two variables have the type Threads which can get very large, in this particular case, I estimate they're each 22kB.

According to valgrind, each exec call ends up with 200 memcpy's - this makes regex! five times slower than the dynamic regex, for me.
Adding a single line recovers performance of the generated code, even if it's only marginally better than the dynamic regex:

let (mut clist, mut nlist) = (&mut clist, &mut nlist);

No other changes are necessary because of deref coercions (as weird as &mut &mut T -> &mut T may be).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions