From: Rob Pike Date: Fri, 20 Nov 2009 19:16:57 +0000 (-0800) Subject: slight simplification made possible by the code now processing match states X-Git-Tag: weekly.2009-12-07~172 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d324a851c4fa14c62895b88dfb32f9f7327e1e04;p=gostls13.git slight simplification made possible by the code now processing match states in order of discovery. R=rsc https://golang.org/cl/157112 --- diff --git a/src/pkg/regexp/regexp.go b/src/pkg/regexp/regexp.go index a58fbf44fe..0b1d97d136 100644 --- a/src/pkg/regexp/regexp.go +++ b/src/pkg/regexp/regexp.go @@ -764,11 +764,10 @@ func (a *matchArena) addState(s []state, inst instr, match *matchVec, pos, end i index := inst.index(); l := len(s); begin := match.m[0]; - // TODO: If the state were a vector and we could do insert, have inputs always - // go in order correctly and this "earlier" test is not necessary, + // States are inserted in order so it's sufficient to see if we have the same + // instruction; no need to see if existing match is earlier (it is). for i := 0; i < l; i++ { - if s[i].inst.index() == index && // same instruction - s[i].match.m[0] <= begin { // earlier match already going; lefmost wins + if s[i].inst.index() == index { return s } }