Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 May 2000 15:00:24 +0200
From:      Martin Cracauer <cracauer@cons.org>
To:        gerald stoller <gerald_stoller@hotmail.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: hashing a symbol before looking into a hashed table
Message-ID:  <20000523150024.A9628@cons.org>
In-Reply-To: <20000522183945.26600.qmail@hotmail.com>; from gerald_stoller@hotmail.com on Mon, May 22, 2000 at 02:39:45PM -0400
References:  <20000522183945.26600.qmail@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In <20000522183945.26600.qmail@hotmail.com>, gerald stoller wrote: 
> I've been looking at the source code for  FreeBSD 3.3  and i noticed that a 
> table-lookUp is called and given the name to look-up and also its  hashed  
> value.  Why is the hashed value supplied, why should the caller even be 
> aware of it (this is strictly internal to the table-lookUp)?  Even if there 
> are differing hashing techniques for various tables, the caller shouldn't 
> have to know which one to use.

When the caller stores the hashed values, the hash values can be
reused for multiple calls.

While reuse could also happen when the caller passed a pointer to a
pointer, which would be filled by the caller if unset, this would lead
to more pointer indirections and/or more complicated memory
allocation.

A typical example why the encapsulation often enforced since the "OO"
programming b(d)oom doesn't lead very far when only slight performance
losses are acceptable.  Either you recompute or you have to store and
follow lots of pointers, which in turn need to be remembered for
resource bookkeeping.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer/
BSD User Group Hamburg, Germany     http://www.bsdhh.org/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000523150024.A9628>