Results 1 to 8 of 8

Thread: Any WordWrap faster

  1. #1

    Thread Starter
    Member EricDalnas's Avatar
    Join Date
    Sep 2004
    Location
    Rhode Island
    Posts
    51
    Maybe if you'd stop breathing and die for a change I wouldn't be so pissed off all the time.

    www.mredkj.com

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Any WordWrap faster

    It isn't the best example, but the theories behind it are probably the fastest way to do it.

    Some of the bad points that I spotted:
    • The textbox (and value of intMaxLineLen) should be passed as a parameters/properties, instead of being coded into the routine. [not speed related - but stops re-usablilty]
    • Instead of just "frmMain.txtHidden" the code should be "frmMain.txtHidden.Text" (or the programmer should be shot! )
    • The hWnd should be stored in a variable at the start of the routine, to reduce the time to retrieve it.
    • As it is only called from one place, the FixBuf function should be moved inline.
    • It may be possible to replace txtHidden with a string variable (I havent checked the code enough, but this would make it much faster), otherwise a With block would help.

  3. #3

    Thread Starter
    Member EricDalnas's Avatar
    Join Date
    Sep 2004
    Location
    Rhode Island
    Posts
    51

    Re: Any WordWrap faster

    Ah thanks for the tips. I wrote that like 6+ years ago because I had to wordwrap gigabytes of text.
    Maybe if you'd stop breathing and die for a change I wouldn't be so pissed off all the time.

    www.mredkj.com

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Any WordWrap faster

    Quote Originally Posted by si_the_geek
    It may be possible to replace txtHidden with a string variable (I havent checked the code enough, but this would make it much faster), otherwise a With block would help.
    Jacob Roman said, he has found speed problem with With block : http://www.vbforums.com/showpost.php...67&postcount=9
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Any WordWrap faster

    There have been many tests on the speed of With blocks, and from what I have seen the general rules are:
    • Using it for single item (eg: "With MyObject") does not yield an improvement, and for some things slows it down.
    • Using it for an array (eg: "With MyObject(MyIndex)") is about the same speed.
    • And using it for a child object (eg: "With MyParentObject.MyObject"), which is used in this case, is faster - as the "chain of reference" does not need to be evaluated each time.
    If you want examples/explanations of these, search for posts on this site by Merri that discuss it, or search the web for VBSpeed and VBFibre.

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Any WordWrap faster

    Then the last level optimization: get rid of processing strings. Basically this means you fake an integer array with no items to point to the string data in memory. This happens by replacing the array header data in memory while the process is going on. However this gets very complex and figuring the fastest way might take a good while: you'd have to solve how to have enough space in the array/string where the end result is being processed into.

    If interested to know how to let an integer array access a string data, take a look into this thread: InStrCount. The code snippet uses the technique to work very fast. The code looks for given string data inside another, counting strings within strings. In binary compare mode only though.

  7. #7
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Any WordWrap faster

    Quote Originally Posted by si_the_geek
    There have been many tests on the speed of With blocks ......... search the web for VBSpeed and VBFibre.
    Thanks. I found VBSPeed and VBFibre.

    But can't find Merri's posts. There are so many results !

    @Merri, please help me find your posts.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Any WordWrap faster

    From the mighty optimisation thread (here) I found this thread which dicusses it:
    http://www.vbforums.com/showthread.php?t=335783

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