• Kyle Consalus's avatar
    Optimization to regexp _CharClass: keep track of overall range of · aae02a18
    Kyle Consalus authored
        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
    aae02a18
regexp.go 30.3 KB