Author Topic: convert BSTR to FBSTRING  (Read 5028 times)

0 Members and 1 Guest are viewing this topic.

Offline Peter Weis

  • Sr. Member
  • ****
  • Posts: 326
  • User-Rate: +15/-4
  • Gender: Male
convert BSTR to FBSTRING
« on: May 05, 2018, 04:02:09 PM »
Basic is not always slower than assembler

Code: [Select]

FUNCTION BSTR_to_FBstr Alias "BSTR_to_FBstr" (ByVal srcBSTR AS BSTR)  AS String Export
  Dim AS LONG i
  Dim AS Byte PTR j
  mov eax, [srcBSTR]
              mov ecx, [eax-4]
              mov [i], ecx
  End ASM
  If i>0 THEN
          s = Space(i)
          j = StrPtr(s)
                 mov esi, [srcBSTR]
                 mov edi, [j]
                 mov ecx, [i] 'length of data
                 Shr ecx, 1
                 rep movsw
                 jnb NotNext
          End ASM
  End If
  Function = s
End Function

This is much faster though written in basic and not with inline code

Code: [Select]

FUNCTION BSTR_to_FBstr2 Alias "BSTR_to_FBstr2" (Byval s AS bstr ptr)  AS String Export
Function = *Cast(zstring Ptr,s)
End Function