From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 09305BBB7 for ; Tue, 25 Jul 2006 14:44:23 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6PCiM9o008446 for ; Tue, 25 Jul 2006 14:44:22 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA15755 for ; Tue, 25 Jul 2006 14:44:22 +0200 (MET DST) Received: from mail-outfwd.lms.be (Kaiserslautern1.lms-gmbh.de [213.68.136.230]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6PCiLR9030404 for ; Tue, 25 Jul 2006 14:44:21 +0200 Received: from localhost (unknown [127.0.0.1]) by mail-outfwd.lms.be (Postfix) with ESMTP id 5E8087F43F for ; Tue, 25 Jul 2006 15:04:20 +0200 (CEST) Received: from mail-kl.lmsintl.com ([127.0.0.1]) by localhost (kl-ftp [127.0.0.1]) (amavisd-new, port 20024) with ESMTP id 25959-10 for ; Tue, 25 Jul 2006 15:04:20 +0200 (CEST) Received: from kaiserslautern1.lmsintl.com (unknown [10.2.0.100]) by mail-kl.lmsintl.com (Postfix) with ESMTP id 4C5A7B6EC6 for ; Tue, 25 Jul 2006 15:04:20 +0200 (CEST) Received: by kaiserslautern1.lmsintl.com with Internet Mail Service (5.5.2653.19) id <32PZS7DR>; Tue, 25 Jul 2006 14:44:21 +0200 Message-ID: <26EB47FDD566A7469FC862DAF373792F017112AD@kaiserslautern1.lmsintl.com> From: Christoph Bauer To: caml-list Subject: AW: [Caml-list] generic Hashtbl.to_array Date: Tue, 25 Jul 2006 14:44:18 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Virus-Scanned: by IT Services X-Miltered: at nez-perce with ID 44C61226.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 44C61225.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; hashtbl:01 hashtbl:01 iter:01 caml-list:01 match:02 guess:03 raise:03 let:03 let:03 christoph:04 christoph:04 exit:04 exit:04 fold:06 cycles:06 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 > > let to_array_4 t = > let init = ref None in > begin try Hashtbl.iter (fun k v -> init := Some (k,v); > raise Exit) t My guess: hashtbl has to loop over the first empty buckets. And this eats the cpu cycles. > with Exit -> () > end; > match !init with > | None -> [| |] > | Some i -> > let a = Array.make (Hashtbl.length t) i in > ignore (Hashtbl.fold (fun k v i -> a.(i) <- (k, v); i > + 1) t 0); > a Regards, Christoph Bauer