Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 4abe023ed3f8fd7072ef7e5e11638ac782b5e1f2
Ticket: 1764318fffffffffffffffffffffffffffffffff
Improve performance of tcl_startOfNextWord and friends...
User & Date: petasis on 2007-07-31 11:09:09
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed 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
    }
    
  4. foundin changed to: "obsolete: 8.4.16"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "petasis"
  10. subsystem changed to: "69. Other"
  11. title changed to:
    Improve performance on tcl_startOfNextWord and friends...
    
  12. type changed to: "Bug"