Skip to content
Tcl Source Code Artifact [30022d55ff]
Login

Artifact [30022d55ff]

Artifact 30022d55ff7f56710bbd175e36214bbd266f9a16:

Ticket change [30022d55ff] - Ticket [a4a7f2abd376b280|a4a7f2abd3] <i>Tcl [string match] and [glob] are exponential complexity for bad patterns, could be linear</i> status still Open with 3 other changes by aku on 2017-05-06 17:41:01.
D 2017-05-06T17:41:01.925
J icomment >\sThis\sdeserves\ssome\scommentary\sin\sthe\scode:\r\n\r\nDefinitely\sneeded,\sIMHO\r\n\r\n>\s>\sYou\shave\s(a)\r\n>\s>\s>\spnext\s=\spattern\s-\s1;\r\n>\s>\s>\ssnext\s=\sstr;\r\n\r\n>\s>\swhere\sRuss\shas\r\n>\s>\s>\snextPx\s=\spx\r\n>\s>\s>\snextNx\s=\snx\s+\s1\r\n\r\n>\spnext\s=\spattern\s-\s1\sbecause\sthe\swhile\sloop\simmmediately\safter\scase\s'*'\r\n>\sincrements\spattern\sto\sthe\scharacter\safter\sthe\sfinal\s*.\r\n\r\nCan\syou\sgive\sme\sline\snumbers,\sbecause\sI\sreally\sdo\snot\ssee\sthat.\r\nTo\sme\s(a)\sis\sat\slines\s1991/2.\sLine\s1994\sis\sthe\sgoto\sto\sline\s1929,\swhich\sis\sthe\sbeginning\sof\sthe\souter\sloop,\sand\simmediately\sgoes\sinto\sthe\sswitch\sagain.\sIn\ssee\sincrementing\sfor\scase\s'*',\sand\sfor\sthe\smatchLiteral\scase.\sThe\sother\scases\sI\sdon't\sreally\ssee.\r\n\r\n>\ssnext\sI\smoved\sthe\sincrement\sto\sthe\sbacktrack\spoint\s(matchFail)\sto\ssave\r\n>\scounting\sunichars\sand\skeep\sthe\scheck\sfor\send-of-string\sout\sof\sthe\smain\r\n>\slogic\sflow.\r\n\r\nThat\smakes\ssense.\r\n\r\n>\sI\swould\sreally\slike\sto\sfactor\ssome\sof\sthe\srepetition\swithin\sthe\sfunction\r\n>\s(all\sthe\sUCHAR\sbits),\spossibly\smove\s[]-handling\sinto\sa\sstatic\sfunction\sto\r\n>\skeep\sthe\smain\sloop\sclearer\s..\r\n\r\nI\ssuspect\swe\swould\sneed\sbenchmarks\sto\ssee\sthe\simpact\sof\smoving\sall\sthis\sinto\sa\sseparate\sfunction.\r\n\r\n>\sand\sif\swe\scould\sget\srid\sof\shaving\salmost\r\n>\sidentical\scode\sin\sByteArrayMatch,\sUniCharMatch\sand\sUniCharCaseMatch\sthat\r\n>\swould\sbe\sa\sbig\swin\simo.\r\n\r\nAs\smuch\sas\sI\swould\slike\sthat\sI\scurrently\sdo\snot\ssee\sit,\swithout\snegatively\simpacting\sperf.\sThe\sframework\sis\sthe\ssame,\syes.\sThe\sexact\sfiddly\sbits\s(mainly\saround\s"go\sto\snext\schar"\sand\s"nocase"-handling)\sOTOH\snot\sso\smuch.\r\n\r\nI\swould\sconsider\sthis\stype\sof\scleanup\sto\sbe\sout\sof\sscope\sfor\sthis\sticket.\r\nShould\smake\sa\sseparate\sticket\sfor\sthat.\r\n\r\n>\sThanks\sfor\sthe\sreview/feedback!
J login aku
J mimetype text/plain
K a4a7f2abd376b2806073d2865f07b7d910b04574
U aku
Z 1b56e21ce558b852979a7e3cad689ff6