Overview
| Artifact ID: | 30022d55ff7f56710bbd175e36214bbd266f9a16 |
|---|---|
| Ticket: | a4a7f2abd376b2806073d2865f07b7d910b04574
Tcl [string match] and [glob] are exponential complexity for bad patterns, could be linear |
| User & Date: | aku on 2017-05-06 17:41:01 |
Changes
- icomment:
> This deserves some commentary in the code: Definitely needed, IMHO > > You have (a) > > > pnext = pattern - 1; > > > snext = str; > > where Russ has > > > nextPx = px > > > nextNx = nx + 1 > pnext = pattern - 1 because the while loop immmediately after case '*' > increments pattern to the character after the final *. Can you give me line numbers, because I really do not see that. To me (a) is at lines 1991/2. Line 1994 is the goto to line 1929, which is the beginning of the outer loop, and immediately goes into the switch again. In see incrementing for case '*', and for the matchLiteral case. The other cases I don't really see. > snext I moved the increment to the backtrack point (matchFail) to save > counting unichars and keep the check for end-of-string out of the main > logic flow. That makes sense. > I would really like to factor some of the repetition within the function > (all the UCHAR bits), possibly move []-handling into a static function to > keep the main loop clearer .. I suspect we would need benchmarks to see the impact of moving all this into a separate function. > and if we could get rid of having almost > identical code in ByteArrayMatch, UniCharMatch and UniCharCaseMatch that > would be a big win imo. As much as I would like that I currently do not see it, without negatively impacting perf. The framework is the same, yes. The exact fiddly bits (mainly around "go to next char" and "nocase"-handling) OTOH not so much. I would consider this type of cleanup to be out of scope for this ticket. Should make a separate ticket for that. > Thanks for the review/feedback!
- login: "aku"
- mimetype: "text/plain"