Page 1 of 1

Searching for strings can easily be a bit faster

Posted: 2016-07-09, 23:33 UTC
by MarcinW
I opened some very large file in Lister and started to search for some strings. Results:

When searching for string "abcdefghij":
"Case sensitive" checkbox off: 140 sec
"Case sensitive" checkbox on: 136 sec

When searching for string "0123456789":
"Case sensitive" checkbox off: 145 sec
"Case sensitive" checkbox on: 140 sec

I repeated this experiment three times and always got same results. In particular, when searching with "Case sensitive" checkbox on, the search process is always faster; this is rather obvious and expected, because file contents don't have to be lowercased or uppercased before the comparison.

But: search results for the "0123456789" string will always be the same, regardless of the "Case sensitive" setting. This is because LowerCase("0123456789") == UpperCase("0123456789") == "0123456789". So, when LowerCase(SearchStr) == UpperCase(SearchStr), the search process could always behave as when "Case sensitive" option is on (which is faster):
if "Case sensitive" checkbox on
=> search case-sensitively
else
if LowerCase(SearchStr) == UpperCase(SearchStr)
=> search case-sensitively // Improvement here
else

=> search case-insensitively

(Note: in Delphi, AnsiLowerCase and AnsiUpperCase should probably be used instead)
This could be used at least in:
- Lister,
- "Find Files" dialog with "Find text" option on.

Regards

Posted: 2016-07-10, 17:03 UTC
by MVV
Well, 5 of 140 seconds is not so much faster to be noticeable...

Posted: 2016-07-10, 20:53 UTC
by MarcinW
Well, my license number is ~270000. If every of 270000 TC users saves 5 seconds of life, this gives two weeks! But some users perform many text searches, so this should probably be counted in months...