Do we need faster regex?
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Mon Dec 18 17:34:04 UTC 2023
If you import std.regex and do nothing else:
sema1 61ms
sema2 101ms
std.internal.unicode_tables:
sema1 4ms
sema2 100ms
https://github.com/dlang/phobos/blob/master/std/internal/unicode_tables.d
Now for:
```d
auto ctr = ctRegex!(`^.*/([^/]+)/?$`);
// It works just like a normal regex:
auto c2 = matchFirst("foo/bar", ctr); // First match found here, if any
assert(!c2.empty); // Be sure to check if there is a match before
examining contents!
assert(c2[1] == "bar"); // Captures is a range of submatches: 0 = full
match.
```
toImpl:
sema3 125ms
parseSet:
Sema3 111ms
findAny (child of parseRegex and parseSet):
CTFE 51ms
While there are improvements to be had, I have already done all the big
ones when I shaved off ~600ms earlier this year.
Gotta love time trace!
More information about the Digitalmars-d
mailing list