jbv wrote:
your suggestion for asking the list for help to optimize speed of a script
is wise, but really, I don't have any such problem right now...

the only thing that just crossed my mind is : what if you want to output the
keys of an array in the same order as you created them ? so far the only
way to do that I can think of is to maintain an extra variable in which you
accumulate keys (as items) when you create them...
may be it's just me, but I would expect Rev to output keys in the same
order as they were created... that would be more handy...

If your order of creation relates to numeric sort order, the fastest solution I can think of offhand is to get the keys, sort them numerically, and use that list to access them.

The sort command is reasonably fast, and while there may be some benefit to also maintaining a separate list of keys as they're created, that option would carry its own overhead (I try to minimize copies of data whenever possible).

> BTW here's a suggestion for a slight improvement of the "keys" function :
>     get the numKeys of myArray  -->  outputs the keys in numeric order
>     get the alphaKeys of myArray  -->  outputs the keys in alphabetic order

Those might be handy indeed -- have you submitted those requests to BZ?

haven't found the time yet...
before I proceed, may be some list members have some better ideas
to improve my proposition ?

The latest "What's New" documented included with the Rev install has this tasty tidbit:

-------------------------------/

Array key iteration
~~~~~~~~~~~~~~~~~~~

A new form of the repeat command has been added:
    repeat for each key tKey of tArray
      ...
    end repeat

This form can be used as a direct replacement for:
    repeat for each line tLine of the keys of tArray
      ...
    end repeat

In cases where tArray has a large number of keys, there is a substantial
speed improvement in using the new form.

-------------------------------\

I wonder if an optimal solution might be to find a graceful way to add the sort params as optional arguments to the repeat statement, maybe something like:

  repeat for each key tKey of tArray sorted numeric ascending


--
 Richard Gaskin
 Managing Editor, revJournal
 _______________________________________________________
 Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to