]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.gadgets.paragraphs: faster pref-dim.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 28 Feb 2020 02:10:37 +0000 (18:10 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 28 Feb 2020 02:10:37 +0000 (18:10 -0800)
Now computing gadget-metrics once, before called (measure-metrics) twice,
the first time adding the result, the second time dropping the top of stack.

basis/ui/gadgets/paragraphs/paragraphs.factor

index 3f7ecca32251a0c78c245113cbdf32aa942b1f53..6ed04ceae1b0b8df3c6850f6207cd004a321abea 100644 (file)
@@ -37,7 +37,7 @@ TUPLE: line words width height baseline ;
 
 : <line> ( words -- line )
     [ ] [ line-width ] [ [ key>> ] map dup pref-dims ] tri
-    [ measure-height ] [ measure-metrics drop ] 2bi line boa ;
+    measure-metrics [ + ] 2keep drop line boa ;
 
 : wrap-paragraph ( paragraph -- wrapped-paragraph )
     [ children>> [ gadget>word ] map ] [ margin>> ] bi