#TUNING by exept
authorClaus Gittinger <cg@exept.de>
Sat, 10 Aug 2019 14:07:02 +0200
changeset 18982 b122ce4e6e60
parent 18981 1cf50cec3108
child 18983 bb34ad441321
#TUNING by exept class: SystemBrowser class changed: #searchBlockForString:ignoreCase:match:fullWordsOnly:resourceMethodsOnly:
SystemBrowser.st
--- a/SystemBrowser.st	Sat Aug 10 09:26:35 2019 +0200
+++ b/SystemBrowser.st	Sat Aug 10 14:07:02 2019 +0200
@@ -5998,7 +5998,10 @@
     "return a block to search for a string."
 
     |checkBlock lineCheckBlock pattern doMatch
-     quickCheckString firstMatchIndex lastMatchIndex stringSearchBlock|
+     quickCheckString firstMatchIndex lastMatchIndex stringSearchBlock
+     caseSensitive|
+
+    caseSensitive := ignoreCase not.
 
     doMatch := doMatchArg.
     aString includesMatchCharacters ifFalse:[
@@ -6026,10 +6029,10 @@
             pattern := pattern,'*'
         ].
         "/ when doing a match, be careful to not match acrosss lines
-        lineCheckBlock := [:line | pattern match:line caseSensitive:ignoreCase not].
+        lineCheckBlock := [:line | pattern match:line caseSensitive:caseSensitive].
         quickCheckString size > 1 ifTrue:[
             checkBlock := [:src | 
-                            (src includesString:quickCheckString caseSensitive:ignoreCase not)
+                            (src includesString:quickCheckString caseSensitive:caseSensitive)
                             and:[ (lineCheckBlock value:src)
                             and:[ src asStringCollection contains:lineCheckBlock ]]].
         ] ifFalse:[    
@@ -6038,7 +6041,18 @@
                             and:[ src asStringCollection contains:lineCheckBlock ]].
         ].
     ] ifFalse:[
-        checkBlock := [:src | src includesString:aString caseSensitive:ignoreCase not]
+        "a regular string"
+        "/ because caseInsensitive searches are slower,
+        "/ check if we can also compare caseInsensitive (i.e. there are no letters in it)
+        (caseSensitive or:[aString conform:[:ch | ch isNationalLetter not]]) ifTrue:[
+            checkBlock := [:src | 
+                (src indexOfSubCollection:aString startingAt:1 ifAbsent:0 caseSensitive:true) ~~ 0 
+            ]
+        ] ifFalse:[
+            checkBlock := [:src | 
+                (src indexOfSubCollection:aString startingAt:1 ifAbsent:0 caseSensitive:false) ~~ 0 
+            ]
+        ].
     ].
     
     stringSearchBlock :=
@@ -6061,7 +6075,7 @@
                         [ 
                             reallyFound not
                             and:[
-                                idx1 := src indexOfSubCollection:aString startingAt:idx1+1 ifAbsent:0 caseSensitive:ignoreCase not.
+                                idx1 := src indexOfSubCollection:aString startingAt:idx1+1 ifAbsent:0 caseSensitive:caseSensitive.
                                 idx1 ~~ 0]
                         ] whileTrue:[
                             "/ see if it is a free-standing word