Announcement

Collapse
No announcement yet.

Save 1K

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

  • Save 1K

    TIP: Using CopyRect instead of LSET saves me almost 1K
    (If you need to copy a RECT of course)


  • #2
    How did you measure that? Remember that the EXE size bears little resemblence to the real memory image... you need to use the compile stats to determine the exact "saving".

    In my simple test to verify your claim using the following code:
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    FUNCTION PBMAIN
    DIM a AS rect
    DIM b AS rect
    ' a = b ' unrem one or the other...
    ' CopyRect a,b
    END FUNCTION

    I get the following code results:
    Code:
    Neither                      a=b                      CopyRect
     592 bytes code               624 code                 608 code
    1103 RTL                     1609 RTL                 1103 RTL
     688 bytes dgroup             688 dgroup               688 dgroup
    1791 bytes memory image      2297 memory image        1791 memory image
    Note that LSET is not required when copying a UDT structure... LSET A=B is the same as A=B, but using LSET adds slightly more code to the application.

    Therefore, the apparent memory saving is 2297-1791 = 506 bytes. If we add the LSET keyword into the A=B line, then the code jumps to 2499-1791=708 bytes.

    Interesting!



    -------------
    Lance
    PowerBASIC Support
    ( mailto:[email protected][email protected]</A> )
    Lance
    mailto:[email protected]

    Comment


    • #3
      I was common to use LSET in VB.
      I know PB can use LSET to copy strings to UDT's etc..

      It's just a tip, useless, many apps won't notice the ~1k added if there 100k or so.

      Just very small apps may gain a bit.

      And (not tested), LSET will only add 1k even if you use it a lot in your app i guess.

      Bye,

      Comment

      Working...
      X