Whitewash (was Re: [squeak-dev] The Trunk: EToys-tfel.249.mcz)

Eliot Miranda eliot.miranda at gmail.com
Fri Sep 23 17:46:36 UTC 2016


Hi All,

    in reading Tobias' much improved code below I noticed that a lot of
code is using Morph>>allMorphs where Morph>>allMorphsDo: would be much
better

On Fri, Sep 23, 2016 at 6:26 AM, <commits at source.squeak.org> wrote:

> Tim Felgentreff uploaded a new version of EToys to project The Trunk:
> http://source.squeak.org/trunk/EToys-tfel.249.mcz
>
> ==================== Summary ====================
>
> Name: EToys-tfel.249
> Author: tfel
> Time: 23 September 2016, 3:26:09.056418 pm
> UUID: 844e5444-0afb-144b-a622-dcb33fbf8597
> Ancestors: EToys-tfel.248
>
> fix the defensive code for updating status morphs in scripts
>
> =============== Diff against EToys-tfel.248 ===============
>
> Item was changed:
>   ----- Method: ScriptInstantiation>>updateAllStatusMorphs (in category
> 'status control') -----
>   updateAllStatusMorphs
>         "Update all status morphs bound to the receiver.  Done with a
> sledge-hammer at present."
>
>         | w |
>         w := self currentWorld.
> +       (w hasProperty: #updateStatusMorph) ifTrue: [^ self].
> +       w setProperty: #updateStatusMorph toValue: true.
> +       Project current addDeferredUIMessage: [
> +               (w valueOfProperty: #updateStatusMorph ifAbsent: [false])
> ifTrue: [
> +                       (w allMorphs select: [:m | (m isKindOf:
> ScriptStatusControl) and:
> +                               [m scriptInstantiation == self]]) do:
> +                               [:aStatusControl | self updateStatusMorph:
> aStatusControl].
> +                       w removeProperty: #updateStatusMorph.
> -
> -       (w hasProperty: #foo) ifFalse: [
> -               w setProperty: #updateStatusMorph toValue: true.
> -               Project current addDeferredUIMessage: [
> -                       (w hasProperty: #foo) ifTrue: [
> -                               w removeProperty: #updateStatusMorph.
> -                               (w allMorphs select: [:m | (m isKindOf:
> ScriptStatusControl) and:
> -                                       [m scriptInstantiation == self]])
> do:
> -                                       [:aStatusControl | self
> updateStatusMorph: aStatusControl]              .
> -                       ]
>                 ]
>         ]
>
>   !
>

So the above could be

updateAllStatusMorphs
"Update all status morphs bound to the receiver.  Done with a sledge-hammer
at present."

| w |
w := self currentWorld.
(w hasProperty: self) ifTrue: [^ self].
w setProperty: self toValue: #updating.
Project current addDeferredUIMessage:
[[w allMorphsDo:
[:m |
((m isKindOf: ScriptStatusControl)
 and: [m scriptInstantiation == self]) ifTrue:
[self updateStatusMorph: m]]]
ensure:
[w removeProperty: self]]

There are quite a few examples like this, even one egregious "ow allMorphs
do: [:m|..." instead of "ow allMorphsDo: [:m|...".  Calling for volunteers
who know Morphic well to go through and make the necessary changes.  This
should help slow machines like RasperryPi a bit.

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160923/90eb10da/attachment.htm


More information about the Squeak-dev mailing list