FindString and ReplaceString slower with #PB_String_NoCase
Posted: Mon Aug 29, 2022 7:46 am
When I run the below code, using the #PB_String_NoCase flag for the FindString() and ReplaceString() commands makes the loop run much slower than without. Surely NOT checking for the case should be faster, because the commands should just test the string as-is?
Reason for asking: I thought if the string had no text, then I should use #PB_String_NoCase to speed it up, but it actually makes it slower.
Reason for asking: I thought if the string had no text, then I should use #PB_String_NoCase to speed it up, but it actually makes it slower.
Code: Select all
Procedure.s RemoveDoubleSpaces(text$)
While FindString(text$," ");,1,#PB_String_NoCase)
text$=ReplaceString(text$," "," ");,#PB_String_NoCase)
Wend
ProcedureReturn text$
EndProcedure
DisableDebugger
start.q=ElapsedMilliseconds()
For a=1 To 500000
text$=RemoveDoubleSpaces("Hello World, How Are You Today?")
Next
time.q=ElapsedMilliseconds()-start
EnableDebugger
Debug time ; 2800 ms without #PB_String_NoCase, but 5700 ms with it?