std.regex performance

Jesse Phillips jessekphillips+D at
Wed Feb 8 13:44:25 PST 2012

I've finely moved to the new regex for some real code. I'm seeing 
a major change in performance when checking if a large number of 
words contain a digit.

The english.dic file contains 134,950 entries

2.056: 0.22sec
2.058: 7.65sec

I don't expect a correction for this would make it in 2.058 as it 
is likely an issue in 2.057.

import std.file;
import std.string;
import std.datetime;
import std.regex;

private int[string] model;

void main() {
   auto name = "english.dic";
   foreach(w; std.file.readText(name).toLower.splitLines)
      model[w] += 1;

   foreach(w; std.string.split(readText(name)))
      if(!match(w, regex(r"\d")).empty)

More information about the Digitalmars-d mailing list