On 13/10/2015 02:20, Mike Doub wrote:
Pass by reference and you can eliminate a memcopy on the initial function call.

-= Mike


That *used* to be true - but (unless my memory is playing tricks again :-), Mark Waddingham said on the list recently that recent (*) versions of LC use a pointer, and only "copy-on-write" - so there would be no saving in this case.

Kind of verified by a very simple benchmark:

using a value of 500,000 I got times of
LC version  normal    pass by ref
6.6              4023         683
7.0.5           1655       1486
8.0              1768       1465

The code used (with apologies - a bit rushed)

constant K = 100
constant KK = 10
on mouseUp
   ask "how often"
   put it into KKK
   repeat K times
      put "a" after tmp
   end repeat
   repeat KK times
      put tmp after tmp
   end repeat
   put the number of chars in tmp
   put the millisecs into t1
   repeat KKK times
      aa tmp
   end repeat
   put " took " & the millisecs - t1 after msg
   put the millisecs into t1
   repeat KKK times
      bb tmp
   end repeat
   put " took " & the millisecs - t1 after msg
end mouseUp

on aa p
  put  char 1 of p into t
end aa

on bb @p
  put  char 1 of p into t
end bb

-- Alex.

On 13/10/2015 02:20, Mike Doub wrote:
Pass by reference and you can eliminate a memcopy on the initial function call.

-= Mike



On Oct 12, 2015, 9:11 PM, at 9:11 PM, Geoff Canyon <gcan...@gmail.com> wrote:
Not quite as concise, but this function is about 3x faster:

function greatestLessThan pList,V
   put empty into R
   repeat for each item i in pList
      if i < V and i > R then put i into R
   end repeat
   return R
end greatestLessThan
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to