From f278cb544786f86e2576f6edbdac9fd4b84c4209 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 31 Jul 2012 22:03:32 -0700 Subject: [PATCH] core-text: cache attribute assoc. --- basis/core-text/core-text.factor | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/basis/core-text/core-text.factor b/basis/core-text/core-text.factor index b23546a74b..ad25e3adb0 100644 --- a/basis/core-text/core-text.factor +++ b/basis/core-text/core-text.factor @@ -34,16 +34,19 @@ FUNCTION: CGRect CTLineGetImageBounds ( CTLineRef line, CGContextRef context ) ; ERROR: not-a-string object ; +MEMO: make-attributes ( open-font color -- hashtable ) + [ + kCTForegroundColorAttributeName ,, + kCTFontAttributeName ,, + ] H{ } make ; + : ( string open-font color -- line ) [ [ dup selection? [ string>> ] when dup string? [ not-a-string ] unless ] 2dip - [ - kCTForegroundColorAttributeName ,, - kCTFontAttributeName ,, - ] H{ } make &CFRelease + make-attributes &CFRelease CTLineCreateWithAttributedString ] with-destructors ;