core-foundation.strings: faster CF>string.
parent
7d65bde037
commit
51641c6e02
|
@ -1,7 +1,8 @@
|
||||||
! Copyright (C) 2008, 2010 Slava Pestov.
|
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien alien.c-types alien.data alien.strings alien.syntax
|
|
||||||
byte-arrays combinators.short-circuit core-foundation
|
USING: accessors alien alien.c-types alien.data alien.syntax
|
||||||
|
byte-vectors combinators.short-circuit core-foundation
|
||||||
core-foundation.arrays core-foundation.data destructors fry
|
core-foundation.arrays core-foundation.data destructors fry
|
||||||
io.encodings.string io.encodings.utf8 kernel math math.order
|
io.encodings.string io.encodings.utf8 kernel math math.order
|
||||||
parser sequences words ;
|
parser sequences words ;
|
||||||
|
@ -81,11 +82,10 @@ FUNCTION: CFStringRef CFCopyTypeIDDescription ( CFTypeID type_id ) ;
|
||||||
: CF>string ( alien -- string )
|
: CF>string ( alien -- string )
|
||||||
dup CFStringGetLength
|
dup CFStringGetLength
|
||||||
[ 0 swap <CFRange> kCFStringEncodingUTF8 0 f ] keep
|
[ 0 swap <CFRange> kCFStringEncodingUTF8 0 f ] keep
|
||||||
4 * 1 + <byte-array> [
|
4 * 1 + <byte-vector> [
|
||||||
dup length
|
underlying>> dup length
|
||||||
{ CFIndex } [ CFStringGetBytes drop ] with-out-parameters
|
{ CFIndex } [ CFStringGetBytes drop ] with-out-parameters
|
||||||
] keep
|
] keep swap >>length utf8 decode ;
|
||||||
swap head-slice utf8 decode ;
|
|
||||||
|
|
||||||
: CF>string-array ( alien -- seq )
|
: CF>string-array ( alien -- seq )
|
||||||
CF>array [ CF>string ] map ;
|
CF>array [ CF>string ] map ;
|
||||||
|
|
Loading…
Reference in New Issue