From: Florent M. <fmo...@li...> - 2008-06-08 19:30:09
|
> In fact, thinking about this a bit more clearly, there's no need to > set the tag at all if all you do is call 'String.unsafe_get', so this > works: > > let hairy_string_of_float (d : float) = > (Obj.magic d : string) > > Be really careful that you don't let the returned "string" escape into > the wild though :-) It still looks like a double to the garbage > collector and it's not a well-formed string either, so any function > other than 'String.unsafe_get' is highly likely to fail. Hi, this hairy version is as fast as the one with the external oneliner C, here are the elapsed times (from Sys.time) for 3_000_000 floats written to /dev/null: 0.51 sec. -- with extern oneliner C 0.50 sec. -- the hairy one wins, well done! -- Cheers Florent |