![]() ![]() And third case is for anything else with multi byte characters: Second way is to do the Ptr loop if the search text is only one byte. ![]() First nothing to do if the text is empty. Here is a final function, which optimizes for three cases. If the text to search is only one byte long, the function may do the Ptr loop and otherwise maybe do a loop with Middle. In a real world application you may make your own Count function, which then uses different ways. Using Split with a temporary array of 1000 strings being so fast is quite a surprise. The result is always the same value with different amounts of time needed.Īs you see, using bytes instead of characters can make a big difference. Running each function 100 times to measure averages.Įach call finds 1000 spaces in the test string. Private Function Count7(s as string) As Integer #Pragma BackgroundTasks False #Pragma NilObjectChecking False Dim m As MemoryBlock = sĭim l As Integer = m.size- 1 Dim c As Integer = 0 For i As Integer = 0 To l ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |