]> gitweb.factorcode.org Git - factor.git/commitdiff
Add a lint check for swap .. swap that can be replaced by dip. Clean up the cases...
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 26 Oct 2011 20:01:04 +0000 (13:01 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 26 Oct 2011 20:01:04 +0000 (13:01 -0700)
basis/opengl/capabilities/capabilities.factor
basis/ui/gadgets/borders/borders.factor
basis/ui/gadgets/presentations/presentations.factor
core/io/encodings/utf8/utf8.factor
extra/lint/lint.factor

index 37bfabc19b696a25808afb350363c63b50ac20da..b1b173177481ee89b95139e85beeb58a40ace176 100644 (file)
@@ -27,7 +27,7 @@ IN: opengl.capabilities
     "." split [ string>number ] map ;
 
 : version-before? ( version1 version2 -- ? )
-    swap version-seq swap version-seq before=? ;
+    [ version-seq ] bi@ before=? ;
 
 : (gl-version) ( -- version vendor )
     GL_VERSION glGetString " " split1 ;
index 90de5a92877d323282b053dff9b5280947db2e1d..a15919658a6d3fc1adade7c9a103630f312d7a98 100644 (file)
@@ -14,8 +14,7 @@ TUPLE: border < gadget
     new swap add-gadget ; inline
 
 : <border> ( child gap -- border )
-    swap border new-border
-        swap >>size ;
+    [ border new-border ] dip >>size ;
 
 : <filled-border> ( child gap -- border )
     <border> { 1 1 } >>fill ;
index 93a585e3308086228616938d8231dc60a74bda49..350b695e22ef6a9e26e225f565c32adc5a4349e8 100644 (file)
@@ -25,8 +25,8 @@ TUPLE: presentation < button object hook ;
     [ [ object>> ] keep show-summary ] [ button-update ] bi ;
 
 : <presentation> ( label object -- button )
-    swap [ invoke-primary ] presentation new-button
-        swap >>object
+    [ [ invoke-primary ] presentation new-button ] dip
+        >>object
         [ drop ] >>hook
         roll-button-theme ;
 
index 8fbc71e016ae26010edd8d53d4716f75f93b0879..44850c0ab850c362df2d5ad34165c03d3993910d 100644 (file)
@@ -16,7 +16,7 @@ SINGLETON: utf8
 
 : append-nums ( stream byte -- stream char )
     over stream-read1 dup starts-2?
-    [ swap 6 shift swap BIN: 111111 bitand bitor ]
+    [ [ 6 shift ] dip BIN: 111111 bitand bitor ]
     [ 2drop replacement-char ] if ; inline
 
 : minimum-code-point ( char minimum -- char )
index 29fd5e9b3afb3d39bfdd29ec26fb5b39427c6ae4..e6710302cce80e804d65b7a774d5853a9d27e501 100644 (file)
@@ -2,10 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: accessors alien arrays assocs classes
-classes.tuple.private combinators.short-circuit fry hashtables
-io kernel kernel.private locals.backend make math namespaces
-prettyprint quotations sequences sequences.deep shuffle
-slots.private vectors vocabs words words.alias ;
+classes.tuple.private combinators.short-circuit continuations
+fry hashtables io kernel kernel.private locals.backend make
+math namespaces prettyprint quotations sequences sequences.deep
+shuffle slots.private splitting stack-checker vectors vocabs
+words words.alias ;
 
 IN: lint
 
@@ -287,6 +288,18 @@ M: word run-lint ( word -- seq ) 1array run-lint ;
 
 PRIVATE>
 
+: find-swap/swap ( word -- ? )
+    def>> [ callable? ] deep-filter
+    [
+        {
+            [ [ \ swap = ] count 2 >= ]
+            [
+                { swap } split rest but-last
+                [ [ infer ] [ 2drop ( -- ) ] recover ( x -- x ) = ] any?
+            ]
+        } 1&&
+    ] any? ;
+
 : lint-all ( -- seq )
     all-words run-lint dup lint. ;