From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA12031; Mon, 5 Nov 2001 11:32:54 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA11720 for ; Mon, 5 Nov 2001 11:32:52 +0100 (MET) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id fA5AWpX15117 for ; Mon, 5 Nov 2001 11:32:51 +0100 (MET) Received: from pc803.lri.fr (IDENT:root@pc803 [129.175.8.114]) by ext.lri.fr (8.11.6/jtpda-5.3.2) with ESMTP id fA5AWpb15836 ; Mon, 5 Nov 2001 11:32:51 +0100 (MET) Received: by pc803.lri.fr (8.9.3/feuille) id LAA27028 ; Mon, 5 Nov 2001 11:32:52 +0100 X-Authentication-Warning: localhost.localdomain: filliatr set sender to filliatr@pc803 using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15334.27347.973997.129488@pc803> Date: Mon, 5 Nov 2001 11:32:51 +0100 (MET) To: "Marcin 'Qrczak' Kowalczyk" Cc: caml-list@inria.fr Subject: Re: [Caml-list] Specialized dictionaries In-Reply-To: References: X-Mailer: VM 6.49 under Emacs 20.4.1 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Marcin 'Qrczak' Kowalczyk writes: > I need dictionaries indexed by ints which must be very fast. I'm > afraid that there is an overhead in using Hashtbl.t such that the > generic hash function must recognize that the value is immediate > instead of using it as a hash directly. > > Is it worth to do something with it? What to do? I could copy the first > half of hashtbl.ml and replace all occurrences of the function hash by > land'ing with 0x3FFFFFFF (so the value is nonnegative and mod gives > nonnegative results). Any better idea? As suggested by Xavier regarding your other question, you can instantiate Hashtbl.Make accordingly: ====================================================================== module IntHashtbl = Hashtbl.Make(struct type t = int let equal = (==) let hash n = n land 0x3FFFFFFF end) ====================================================================== To be even more efficient, I'm afraid you have to follow your idea, that is to inline this hash function in your own copy of hashtbl.ml. -- Jean-Christophe Filliatre (http://www.lri.fr/~filliatr) ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr