]> Cypherpunks repositories - gostls13.git/commit
Optimization to regexp _CharClass: keep track of overall range of
authorKyle Consalus <consalus@gmail.com>
Thu, 3 Jun 2010 06:04:44 +0000 (23:04 -0700)
committerRob Pike <r@golang.org>
Thu, 3 Jun 2010 06:04:44 +0000 (23:04 -0700)
commitaae02a1855b162bdd0a1cce7707f0bc8054834d1
treec429401844a261509fa862128869a1a1250be26b
parent3d4c97b82c90ee94400c40475207ff858fc88fb2
Optimization to regexp _CharClass: keep track of overall range of
    charclass to avoid unnecessarily iterating over ranges.
    Also, use the fact that IntVector is an []int to avoid method calls.
    On my machine, this brings us from ~27500 ns/op to ~17500 ns/op in the benchmark I've added (it is also faster in the case where a range check
    doesn't help, added a benchmark for this too.)

    I'd also like to propose that "[]", and "[^]" be disallowed. They aren't useful as far as I can tell, they aren't widely supported, and they make reasoning about character classes a bit more complicated.

R=r
CC=golang-dev
https://golang.org/cl/1495041
src/pkg/regexp/all_test.go
src/pkg/regexp/regexp.go