]> gitweb.factorcode.org Git - factor.git/commitdiff
models: some cleanup.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 30 Nov 2014 06:37:59 +0000 (22:37 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 30 Nov 2014 06:37:59 +0000 (22:37 -0800)
basis/models/models.factor

index 59a04f8031620b2c11c7aa2f7ba94b0b17121217..149a97ff59b328bd4f223505939808b707e33368 100644 (file)
@@ -30,10 +30,10 @@ GENERIC: model-activated ( model -- )
 M: model model-activated drop ;
 
 : ref-model ( model -- n )
-    [ 1 + ] change-ref ref>> ;
+    [ 1 + dup ] change-ref drop ;
 
 : unref-model ( model -- n )
-    [ 1 - ] change-ref ref>> ;
+    [ 1 - dup ] change-ref drop ;
 
 : activate-model ( model -- )
     dup ref-model 1 = [
@@ -57,17 +57,17 @@ DEFER: remove-connection
 GENERIC: model-changed ( model observer -- )
 
 : add-connection ( observer model -- )
-    dup connections>> empty? [ dup activate-model ] when
-    connections>> push ;
+    dup connections>>
+    [ empty? [ activate-model ] [ drop ] if ]
+    [ push ] bi ;
 
 : remove-connection ( observer model -- )
-    [ connections>> remove! drop ] keep
-    dup connections>> empty? [ dup deactivate-model ] when
-    drop ;
+    [ connections>> remove! ] keep swap
+    empty? [ deactivate-model ] [ drop ] if ;
 
 : with-locked-model ( model quot -- )
     [ '[ _ t >>locked? @ ] ]
-    [ drop '[ _ f >>locked? drop ] ]
+    [ drop '[ f _ locked?<< ] ]
     2bi [ ] cleanup ; inline
 
 GENERIC: update-model ( model -- )