FastStringSplit improve speed ...

Share your advanced PureBasic knowledge/code with the community.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: FastStringSplit improve speed ...

Post by skywalk »

nco2k wrote:>> SplitC() does not catch a trailing null?
yes, thats by design. why would you want to do that anyway? i mean you can change it if you really want to, i just dont see the point.
It is the same issue I mentioned prior: "1,2,3,," Splits to [1][2][3][][]. 5 members with 2 nulls.

>> My Split() uses a CountString() at beginning.
not a good idea. browsing through the string twice, will give you terrible performance. this might be ok for such a small string, but now try it with a large string. the bigger the string is, the more your procedure will fall behind. and dont use a string parameter. use a pointer instead: http://www.purebasic.fr/english/viewtop ... 98#p513698
Thanks, I have refactored some functions based on your suggestion. I will post delta times later.
EDIT:
Updated my prior Split() code with nco2k's suggestions and ran speed comparisons for short and long strings vs several Split() approaches.
EDIT2:
Modified nco2k's SplitC() to retain final trailing null's. Shaved some more time off Split(). All the Splitxx() routines now return same number of strings for a given input.
EDIT3:
nco2k simplified SplitC() further, shaving off more ms.
EDIT4:
Modified Split(),SplitC() to avoid 'Pointer is null' if pointing to an array element = Empty$.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
highend
Enthusiast
Enthusiast
Posts: 123
Joined: Tue Jun 17, 2014 4:49 pm

Re: FastStringSplit improve speed ...

Post by highend »

Trying to compile the code from
viewtopic.php?p=516077#p516077
for a x64 executable leads to:

Code: Select all

Line xx: _wcslen_() is not a function, array, list, map or macro
How to fix that?
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: FastStringSplit improve speed ...

Post by Demivec »

highend wrote: Thu Jul 22, 2021 10:36 pm Trying to compile the code from
viewtopic.php?p=516077#p516077
for a x64 executable leads to:

Code: Select all

Line xx: _wcslen_() is not a function, array, list, map or macro
How to fix that?
Looking at the code, it appears to be a typo. Correct it to read '_wcslen()' instead of '_wcslen_()'.
highend
Enthusiast
Enthusiast
Posts: 123
Joined: Tue Jun 17, 2014 4:49 pm

Re: FastStringSplit improve speed ...

Post by highend »

Correct it to read '_wcslen()' instead of '_wcslen_()'
Unfortunately, this doesn't work either.

This works:

Code: Select all

ImportC ""
  wcsstr(*str1, *str2)
  wcslen(*str)
EndImport
and replacing all "_" for wcsstr + wcslen in the procedure...
Post Reply