Manipulating large qtys of text - Wow!

Geoff Canyon gcanyon at inspiredlogic.com
Wed May 15 23:26:01 EDT 2002


At 7:35 PM -0600 5/15/02, Barry Levine wrote:
>Holy smoke! 66 ticks is all it took to do 5500 lines (instead of the 120+ seconds). Looking over the code, it appears that populating a new variable is substantially faster than changing an existing one. ("Substantially"? That's an understatement!) This is great stuff to know! Probably would make an excellent tip for the RunRev website, eh?

It's not the difference between creating a new variable and changing an existing one. It's that, when you're changing an existing variable, you're doing it by changing a particular line. That means that when tNum is 4999,

  put tNum into item 1 of line tNum of tVar

forces the engine to go through tVar looking for 4998th carriage return; then when tNum is 5000 the engine has to go through again looking for the 4999th carriage return, etc. The larger the number of lines, the worse the problem gets.

Building up the variable from scratch means that the engine only has to put things at the end, so it's a lot faster, and the speed should go linearly with the size of the task.
-- 

regards,

Geoff Canyon
gcanyon at inspiredlogic.com



More information about the use-livecode mailing list