Results 1 to 40 of 60

Thread: argh! count number of full stops??

Hybrid View

  1. #1
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: argh! count number of full stops??

    VB Code:
    1. [
    2.     uuid(842b47f0-0b27-11da-8cd6-0800200c9a66),
    3.     version(0.1),
    4.     helpstring("Win32 API Kernel32.DLL")
    5. ]
    6. library Win32Stuff
    7. {
    8.     importlib("stdole2.tlb");
    9.  
    10.     [dllname("kernel32")]
    11.  
    12.     module kernel32
    13.     {
    14.         [
    15.             entry("RtlMoveMemory")
    16.         ]
    17.         VOID CopyMemory ([in,out] LONG* lpDestination, [in,out] LONG* lpSource, [in] LONG Length);
    18.     }
    19. }

    Compile this using MkTypLib (you may need to set a few path environment variables) remove 'CopyMemory' from your declare list and reference the compiled type library.

    I get around 18% performance boost.

    VB Code:
    1. Public Function Sisic4(ByVal pStr As Long, ByVal pFind As Long, ByVal lenStr As Long, ByVal lenFind As Long) As Long
    2.  
    3.     Dim i As Long
    4.     Dim j As Long
    5.     Dim Flag As Long
    6.    
    7.     CopyMemory VarPtr(BufStr(0)), ByVal pStr, ByVal lenStr
    8.     CopyMemory VarPtr(BufFind(0)), ByVal pFind, ByVal lenFind
    9.    
    10.     i = lenStr - 1
    11.    
    12.     If lenFind = 2 Then
    13.         Do Until i < lenFind
    14.             If BufStr(i - 1) = BufFind(0) Then
    15.                 Sisic4 = Sisic4 + 1
    16.             End If
    17.             i = i - 2
    18.         Loop
    19.     Else
    20.         Do Until i < lenFind
    21.             Flag = 0
    22.             j = lenFind - 1
    23.             Do Until j < 0
    24.                 If Not (BufStr(i - (lenFind - j)) = BufFind(j - 1)) Then
    25.                     Flag = -1
    26.                     Exit Do
    27.                 End If
    28.                 j = j - 2
    29.             Loop
    30.             If Flag = 0 Then
    31.                 Sisic4 = Sisic4 + 1
    32.             End If
    33.             i = i - 2
    34.         Loop
    35.     End If
    36.    
    37. End Function
    .. note the varptr function is used to get the ptr to the first array entry.
    Last edited by yrwyddfa; Sep 5th, 2005 at 04:46 AM.
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width