Artifacts Associated With Ticket 1764318
Ticket change [4abe023ed3] (rid 126579) by petasis on 2007-07-31 11:09:09:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi all, I have recently noticed that the file word.tcl in the tcl library has not been updated to use the (relatively) new -start option of regexp. Changing the file word.tcl to remove [string range ...] call and use the -start regexp option, all the procs were made much faster, especially for large strings. As an example, the body of tcl_startOfNextWord: proc tcl_startOfNextWord {str start} { global tcl_nonwordchars tcl_wordchars if {[regexp -indices "$tcl_wordchars*$tcl_nonwordchars+$tcl_wordchars" \ [string range $str $start end] result]} { return [expr {[lindex $result 1] + $start}] } return -1 } Can be changed to: proc tcl_startOfNextWord {str start} { global tcl_nonwordchars tcl_wordchars if {[regexp -indices -start $start -- \ "$tcl_wordchars*$tcl_nonwordchars+$tcl_wordchars" \ $str result]} { return [lindex $result 1] } return -1 } - foundin initialized to: "obsolete: 8.4.16"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "petasis"
- subsystem initialized to: "69. Other"
- title initialized to:
Improve performance on tcl_startOfNextWord and friends...
- type initialized to: "Bug"
Ticket change [f2fbd6816b] (rid 109651) by petasis on 2007-07-31 18:10:19:
- priority changed to: "3 Low"
- title changed to:
Improve performance of tcl_startOfNextWord and friends...
Ticket change [fede8b052f] (rid 108658) by dgp on 2007-08-01 11:39:42:
- assignee changed to: "dgp"
- priority changed to: "7 High"
- subsystem changed to: "38. Init - Library - Autoload"
Ticket change [7bdb319bbf] (rid 96976) by dkf on 2007-08-01 22:21:36:
- assignee changed to: "dkf"
- closedate changed to: "2007-08-01T15:21:36"
- closer changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 Originator: NO Reworked so that code is much more efficient (avoids repeated recompilation of regular expressions, uses -start, etc.) To illustrate, here's the committed version of tcl_startOfNextWord: proc tcl_startOfNextWord {str start} { variable ::tcl::WordBreakRE set result {-1 -1} regexp -indices -start $start $WordBreakRE(next) $str result return [lindex $result 1] } That's about as efficient as we're going to get. :-) Note that not all operations can take full advantage of the efficiency gains. Can't be helped. - login: "dkf"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "dkf"