Refactoring is your friend / moving from 6.x to 9.x

Tom Glod tom at makeshyft.com
Sun Dec 30 23:52:56 EST 2018


a very interesting thread ...lots to learn.

I refactored a project from 7 to 9 .... and definitely had a couple of "how
did this code ever work?" moments, meaning i found the most recent versions
of the engine to be more strict with syntax.

As far as performance comparisons I don't have a lot to add, for me LC has
always been performant enough for the most part.   When I hear about
possible future optimizations I am thrilled to think my software will be
that much more performant.

When something is slow I often just blame my computer. lol but populating
fields seems something that has gotten a lot slower..... so I've had to
work around it a bit.  (built my handler to not put more text into a field
than what is visible, solved my particular problem, but not a universal
solution.)

These kinds of threads are gold mines.  Thanks to all.








On Sun, Dec 30, 2018 at 6:40 PM Ralph DiMola via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Task: Add ellipses if text does not fit visible field width.
>
> V4, v5 and v6 I put the data into the field and then looped thru the lines.
> If text was too wide I chopped off 1/2 of the overflow chars(rough guess)
> and then iterated what was left using the formattedwidth as the last chars
> were deleted with the added ellipses to see if it's all visible.
>
> Simple enough but as 7, 8, 9 were released this became very slow. On
> Android
> device using v9 a list 200-300 hundred lines long(only 25 visible) took
> about 6 seconds to render with the screen locked. I never timed it but it
> seemed like the time increased exponentially as the list grew.
>
> Refactor:
> 1) Insert the field text/styles using a pre-loaded styledText array
> 2) Calculating the ellipses in that array using the measureText function.
> Now the same list took about 1.5 seconds. That's about 4 times faster and
> the seems that the time is more linier as the list grows.
>
> That begs 2 questions for me(at least)
> 1) A charAtPixel function in the engine would make the adding ellipses much
> faster.
> 2) When operating on a field that was hidden, screen locked or you just
> don't care if you see delayed changes.... Have the field object only
> operate
> on an internal styledText array and only start the "go down the hall, into
> a
> room, open the closet... as Richard's prose said" when you want to render
> the field on the screen. Now there may be times for reasons I can't think
> of
> right now that the internal styledText array might need to be flushed to
> the
> field before the field is visible or the screen is unlocked.
>
> Ralph DiMola
> IT Director
> Evergreen Information Services
> rdimola at evergreeninfo.net
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list