> On 25 Mar 2016, at 17:37, Claes Redestad <[email protected]> wrote: > > Interesting, my only concern is we'd add more code/complexity, but it seems > the shift will always be == len when not matching a character in src (the > proof is left out as an exercise), so this can be simplified further to: > > byte c = b[i + j]; > if (c >= ' ' && c <= 'z') { > if (c >= 'a') c -= 32; // Canonicalize > > if (c != src[j]) { > // no match > int goodShift = (j < len - 1) ? len : 1; > int badShift = lastOcc[c - 32]; > i += Math.max(j + 1 - badShift, goodShift); > continue next; > } > } else { > // no match, character not valid for name > i += len; > continue next; > } > > http://cr.openjdk.java.net/~redestad/8152733/webrev.03/ >
Nice, that’s quite clear in it’s intent. As long as this meets the performance goals i am ok with this being slower than other variants, as i think the reduction in static footprint is a fare trade in this case. Paul. > (included Steve's suggestion) > > Since this avoids reading from lastOcc for anything but the chars actually > matching, this actually seems to improve things a bit locally, so I'm willing > to accept the pile-on. I'll run some numbers in the lab... > > /Claes
