From 870670e4d40ffddec9c1fda18e8dabfeaa3d9afe Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 3 Jul 2020 08:39:53 +0000 Subject: In tcl_startOfPreviousWord, don't bother doing a regexp when $start <= 0. --- library/word.tcl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/word.tcl b/library/word.tcl index 3e4bc3a..4e57479 100644 --- a/library/word.tcl +++ b/library/word.tcl @@ -146,7 +146,9 @@ proc tcl_startOfNextWord {str start} { proc tcl_startOfPreviousWord {str start} { variable ::tcl::WordBreakRE set word {-1 -1} - regexp -indices -- $WordBreakRE(previous) [string range $str 0 $start-1] \ - result word + if {$start > 0} { + regexp -indices -- $WordBreakRE(previous) [string range $str 0 $start-1] \ + result word + } return [lindex $word 0] } -- cgit v0.12