]> gitweb.factorcode.org Git - factor.git/commitdiff
cocoa.plists: use new NSFastEnumeration>hashtable word.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 8 Jul 2014 23:12:41 +0000 (16:12 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 8 Jul 2014 23:12:41 +0000 (16:12 -0700)
basis/cocoa/enumeration/enumeration.factor
basis/cocoa/plists/plists.factor

index f4d1053f0ade9758c6be5f7b00de78d763adb695..a78a29bd7ff1f079c0bac0f40a95249024aedbe6 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel classes.struct cocoa cocoa.runtime cocoa.types alien.data
-locals math sequences vectors fry libc destructors specialized-arrays ;
+USING: accessors alien.data assocs classes.struct cocoa
+cocoa.runtime cocoa.types destructors fry hashtables kernel libc
+locals sequences specialized-arrays vectors ;
 SPECIALIZED-ARRAY: id
 IN: cocoa.enumeration
 
@@ -32,3 +33,7 @@ CONSTANT: NS-EACH-BUFFER-SIZE 16
 
 : NSFastEnumeration>vector ( object -- vector )
     [ ] NSFastEnumeration-map ;
+
+: NSFastEnumeration>hashtable ( ... object quot: ( ... elt -- ... key value ) -- ... vector )
+    NS-EACH-BUFFER-SIZE <hashtable>
+    [ '[ @ swap _ set-at ] NSFastEnumeration-each ] keep ; inline
index 0ac7a432291da796f55effe91f249c3097215b10..63662d548992a968d21792d84d80aba69c53470c 100644 (file)
@@ -30,8 +30,8 @@ DEFER: plist>
     [ plist> ] NSFastEnumeration-map ;
 
 : (plist-NSDictionary>) ( NSDictionary -- hashtable )
-    dup [ [ nip ] [ -> valueForKey: ] 2bi [ plist> ] bi@ 2array ] with
-    NSFastEnumeration-map >hashtable ;
+    dup [ [ nip ] [ -> valueForKey: ] 2bi [ plist> ] bi@ ] with
+    NSFastEnumeration>hashtable ;
 
 : (read-plist) ( NSData -- id )
     NSPropertyListSerialization swap kCFPropertyListImmutable f