From owner-freebsd-hackers Tue May 23 6: 0:31 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from gilgamesch.bik-gmbh.de (T1-Hansenet.BIK-GmbH.de [192.76.134.246]) by hub.freebsd.org (Postfix) with ESMTP id 3933737B6CF for ; Tue, 23 May 2000 06:00:28 -0700 (PDT) (envelope-from cracauer@gilgamesch.bik-gmbh.de) Received: (from cracauer@localhost) by gilgamesch.bik-gmbh.de (8.9.3/8.7.3) id PAA09975; Tue, 23 May 2000 15:00:24 +0200 (MET DST) Date: Tue, 23 May 2000 15:00:24 +0200 From: Martin Cracauer To: gerald stoller Cc: hackers@FreeBSD.ORG Subject: Re: hashing a symbol before looking into a hashed table Message-ID: <20000523150024.A9628@cons.org> References: <20000522183945.26600.qmail@hotmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <20000522183945.26600.qmail@hotmail.com>; from gerald_stoller@hotmail.com on Mon, May 22, 2000 at 02:39:45PM -0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 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