Version française
Home     About     Download     Resources     Contact us    
Browse thread
symbol managment in Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sven LUTHER <luther@d...>
Subject: Re: symbol managment in Caml
On Fri, Feb 25, 2000 at 01:16:22PM +0100, Stephan Houben wrote:
> Hello list,
> 
> I am writing an interpreter for a simple language in O'Caml.
> The interpreter often needs to search a hash table with a string
> as key. A common optimization for this is to use pointer identity
> instead of string equality, and "intern" every string before using
> it as a key to the hash table.
> 
> Unfortunately, I don't see how to do this with the current O'Caml
> libs. You can do identity checks with ==, but there seems no way
> to get a good hash corresponding to ==.
> 
> Has anyone already written some code for this task?

Be carefull about this, i had the same kind of idea, but found out that using
references in ocaml is not necessarily a good way of increasing speed, since
some kind of references operation are expensive, and can even trigger a minor
garbage collection wich can in turn start a major garbage collection, thus
making it very expensive.

i was using a small associative list (~15 entries) and it resulted that it was
faster than the reference using version.

Friendly,

Sven LUTHER