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 KAA25340; Fri, 25 Oct 2002 10:40:09 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 KAA25555 for ; Fri, 25 Oct 2002 10:40:08 +0200 (MET DST) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9P8e7514500; Fri, 25 Oct 2002 10:40:07 +0200 (MET DST) Received: by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id KAA0000030588; Fri, 25 Oct 2002 10:40:06 +0200 (MET DST) From: Luc Maranget Message-Id: <200210250840.KAA0000030588@beaune.inria.fr> Subject: Re: [Caml-list] Again on pattern matching and strings To: luther@dpt-info.u-strasbg.fr (Sven Luther) Date: Fri, 25 Oct 2002 10:40:06 +0200 (MET DST) Cc: luc.maranget@inria.fr (Luc Maranget), alex@baretta.com (Alessandro Baretta), garrigue@kurims.kyoto-u.ac.jp (Jacques Garrigue), caml-list@inria.fr (Ocaml) In-Reply-To: <20021024162629.GA4395@iliana> from "Sven Luther" at oct 24, 2002 06:26:29 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > To sum it up for strings : strings are atoms to the PM compiler which > > never look into them, it only compares one string against another, for > > equality only. The match compiler does not make avantage of the known > > pattern string in any sense. The match compiler does not make > > avantage of the existence of a lexical ordering on strings. In fact > > many << optimizations >> are posible here, none is performed. > > So, i suppose replacing all strings in a pattern matching by an integer > pointing to hashtable or something would improve performance a lot if > the same string is pattern matched over and over again ? > > Friendly, Indeed, but there are other possibilities, such as tries. In the style match x with | "a" -> 1 | "ab" -> 2 | "abc" -> 3 | _ -> 4 ===> switch get_char 0 x with | 'a' -> begin switch get_char 1 x with | eos -> 1 (* end of string ... *) | 'b' -> (switch get_char 2 x with ...) | _ -> 4 end | _ -> 4 Where switch operates on machine integers. > > Sven Luther > --Luc ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners