Leaderboard
Popular Content
Showing content with the highest reputation on 06/13/21 in all areas
-
Fast Pos & StringReplace for 64 bit
Tom de Neef posted a topic in Algorithms, Data Structures and Class Design
I've seen several queries about 64 bit equivalents for the fast string routines in Win32. And I needed them myself as well. I have published (assembly based) functions that mimic system.Pos and sysUtils.StringReplace for 32 & 64 bit compiling (both String and AnsiString). Extra feature: searching can be case sensitive or case insensitive. Timing for string search (1k substrings in 1M string, microsec, see documentation; NextStrPos is new): mode 32 bit 64 bit search System.pos NextStrPos System.pos NextStrPos String 550 500 730 400 ANSIstring 530 460 3.500 360 Timing for String replace (1k substrings in 1M string, microsec, see documentation; StrReplace is new): mode 32 bit 64 bit replace SysUtils. StringReplace StrReplace SysUtils. StringReplace StrReplace String 6.500 1.050 6.000 1.050 ANSIstring 7.400 900 7.000 850 Files and documentation on https://sourceforge.net/projects/delphi-fast-pos-stringreplace/ -
Fast Pos & StringReplace for 64 bit
Tom de Neef replied to Tom de Neef's topic in Algorithms, Data Structures and Class Design
And I correct the timings. As someone wrote, they vary a lot with circumstances. But the relativities are a reasonable indication. SEARCH: mode 32 bit 64 bit search System.pos NextStrPos System.pos NextStrPos String 550 250 650 135 ANSIstring 530 460 3.500 65 REPLACE: mode 32 bit 64 bit replace SysUtils. StringReplace StrReplace SysUtils. StringReplace StrReplace String 6.500 1.050 6.000 800 ANSIstring 7.400 900 7.000 650 -
Fast Pos & StringReplace for 64 bit
Tom de Neef replied to Tom de Neef's topic in Algorithms, Data Structures and Class Design
Thanks for the report - I've corrected. The functions are meant for repeated searches: var t : TstrPosRec; k : integer; begin t:=SetupStrPos(target,source,ignoreCase); repeat k:=NextStrPos(t); if k=0 then break; // user code, based on k until false; Thus the initialization overhead is outside the loop. When you code like this: k:=1-target.length; repeat k:=StrPos(target,source,k+target.length); if k=0 then break; // user code, based on k until false; you bring all the initialization within the loop. The StrPos function is provided only as a replacement for system.pos (and does not offer ignoreCase for that reason).