shoe: improve +on-load logic

Turns out that if we use a tag we can just check the value without
needing vase operations.
This commit is contained in:
Fang 2020-05-26 23:10:54 +02:00
parent 41448d5b05
commit 509fec7f7c
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -165,7 +165,7 @@
=^ cards shoe on-init:og =^ cards shoe on-init:og
[(deal cards) this] [(deal cards) this]
:: ::
++ on-save !>([shoe-inner=on-save:og shoe-self=state]) ++ on-save !>([%shoe-app on-save:og state])
:: ::
++ on-load ++ on-load
|= old-state=vase |= old-state=vase
@ -173,22 +173,14 @@
:: we could be upgrading from a shoe-less app, in which case the vase :: we could be upgrading from a shoe-less app, in which case the vase
:: contains inner application state instead of our +on-save. :: contains inner application state instead of our +on-save.
:: to distinguish between the two, we check for the presence of our own :: to distinguish between the two, we check for the presence of our own
:: +on-save faces in the vase. :: +on-save tag in the vase.
:: ::
|^ ?. worn ?. ?=([%shoe-app ^] q.old-state)
=^ cards shoe (on-load:og old-state) =^ cards shoe (on-load:og old-state)
[(deal cards) this] [(deal cards) this]
=^ old-inner state !<([vase state-0] old-state) =^ old-inner state +:!<([%shoe-app vase state-0] old-state)
=^ cards shoe (on-load:og old-inner) =^ cards shoe (on-load:og old-inner)
[(deal cards) this] [(deal cards) this]
::
++ worn
&((have %shoe-inner) (have %shoe-self))
::
++ have
|= =term
(head (mule |.((slab term -:old-state))))
--
:: ::
++ on-poke ++ on-poke
|= [=mark =vase] |= [=mark =vase]