Announcement

Collapse
No announcement yet.

Any way to speed this up ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Any way to speed this up ?

    Hello everyone,

    Anyway to speed this up without assembler ?

    bData is a string containing the contents of a file.

    Code:
     Dim aByte(Len(bData)) As Byte
    
     For c = 1 To Len(bData)
         aByte(c - 1) = Asc(Mid$(bData, c, 1))
     Next
     let Blobdata = aByte()
    Blobdata is a Variant

    Thanks in advance,
    Steven
    So here we are, this is the end.
    But all that dies, is born again.
    - From The Ashes (In This Moment)

  • #2
    Hi,

    following tweaks work in PB/WIN 8.04

    Way #1
    on my PC I got 90% speed boost when replacing:
    Code:
    aByte(c - 1) = ASC(MID$(bData, c, 1))
    with
    Code:
    aByte(c - 1) = Asc(bData, c)
    Way #2
    But if bData is STRING, you can use magic trick allowing avoiding of any loops.
    Code:
     DIM aByte(LEN(bData)-1) AS BYTE AT STRPTR(bData)    
    
     ' -- Yes, no loop here
    
     let Blobdata = aByte()
    ... using this approach the aByte array will be filled with ASCII values immediately. Lightning fast, much faster than "Way #1"


    Bye,
    Petr
    Last edited by Petr Schreiber jr; 3 Dec 2007, 03:57 AM.
    [email protected]

    Comment


    • #3
      MoveMemory( Byval VarPtr( aByte(0) ), ByVal StrPtr( bData ), Len(bData) )
      hellobasic

      Comment


      • #4
        >DIM aByte(LEN(bData)-1) AS BYTE AT STRPTR(bData)

        Even better..
        hellobasic

        Comment


        • #5
          thanks

          Thank you for looking into this !

          Kind Regards
          Steven
          So here we are, this is the end.
          But all that dies, is born again.
          - From The Ashes (In This Moment)

          Comment

          Working...
          X