It isn't the "put" command that's the problem, it's the field text
reformatting routines and redraw. While I'd disagree that your
example runs unacceptably slow (it tracks well enough here to be at
least usable), this overhead is why it's a not a good idea to use
fields as containers in calculation intensive scripts. Instead, put
the field contents into a variable, operate on the variable, then put
the results back into the field afterwards.
You can dramatically improve the performance of your example by not
setting the field contents unless the mouseLoc has changed. For
example:
on mouseDown
put the mouseLoc into oldloc
repeat while the mouse is down
if the mouseLoc is not oldloc then
put the mouseLoc into oldloc
set the loc of me to oldloc
put oldloc into field 1
end if
end repeat
end mouseDown
Note that setting the loc of an object repeatedly to the same value
doesn't cause this problem because controls are smart enough not to
redraw themselves unless they've actually moved. For example, putting
a "hide me"/"show me" pair in place of setting the field contents
results in a similar performance degradation. Unfortunately, the
field control isn't as smart about optimizing away repeatedly putting
the same value into it :-(
While most of this reformatting/redraw overhead can't be avoided, it
should be possible to optimize the field control some (e.g., don't
calculate the formattedWidth if dontWrap is true and don't calculate
formattedHeight when there's no vertical scrollbar). Optimizing
things like this is a high priority for 2.0 so it's good that you
pointed it out. Are there any other areas where improving performance
would be especially useful?
> Note that using an idle handler like mouseStillDown works better, but
> is fairly chunky due to the idle time. (The idle time can be made
> smaller, but I'm not sure what other effects this will have)
I can't see why this would be better unless you're running across a
highly loaded network or to a slow X server, in which case the script
could get way ahead of the object redrawing. The repeat-loop approach
should be a lot faster when running on a local system or between two
relatively balanced systems.
Scott
> -Earle
>
> --
> Earle Lowe
> emlowe@fsa.ca
> FSA Corporation
> Performance and system software for UNIX networks.
-- *********************************************************************** * Scott Raney 303-447-3936 Remember: the better you look, * * raney@metacard.com the more you'll see -- Lidia * ***********************************************************************