Searching for strings can easily be a bit faster

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Searching for strings can easily be a bit faster

Post 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
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Well, 5 of 140 seconds is not so much faster to be noticeable...
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post 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...
Post Reply