Jacque,

those two code snippets do slightly different things - and I don't think either of them is doing exactly what's intended; I think the intent is to delete stack(s) called (exactly) "test".

The first one will (wrongly) catch a stack called "testabc" or "abctest" - and then will fail on deleting 'test'.

The second one also catches "testabc" - but in this case deletes it unintentionally.

Alternatively, we could go straight to the point

put the milliseconds into tStart
repeat forever
  try
     delete stack "test"
  catch tmp
    exit repeat
  end
end repeat
answer the milliseconds - tStart

again, the timings are overlapping - the variation between different runs far outweighs the difference between the methods. I think that could be different if there many other mainstacks in play, but I don't see that it would be significant in any realistic case.

So pick the one that seems  most easily read and understood :-)

Alex.

On 05/04/2023 20:27, J. Landman Gay via use-livecode wrote:
I just created four same-named stacks and ran my suggested handler wrapped with timer commands. All four were deleted in 67 milliseconds. LC 10.0.0 DP 4.

put the milliseconds into tStart
repeat while "test" is in the mainstacks
   delete stack "test"
end repeat
answer the milliseconds - tStart

Ralph's idea to use filter is good too but slightly slower, at (a fairly insignificant) 79 milliseconds:

put the milliseconds into tStart
filter the mainstacks with "test*" into tStacks
repeat for each line l in tStacks
   delete stack l
end repeat
answer the milliseconds - tStart

On 4/5/23 10:15 AM, Bob Sneidar via use-livecode wrote:
Whoa! No I'm not! There's over 300 mainstacks just from Livecode!

Bob S


On Apr 5, 2023, at 08:07, Bob Sneidar via use-livecode <use-livecode@lists.runrev.com> wrote:

Oooh Pro Tip #276 from Jacque. I'm gonna use that one.

Bob S

_______________________________________________
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