[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

# Re: my kingdom for a hash table!

- Date: Tue, 01 Jul 97 12:58:28 -0400
- From:
- cc: asb@media.mit.edu, moo-cows@the-b.org
- In-reply-to: Your message of "Mon, 30 Jun 97 17:39:06 PDT." <199707010039.RAA23382@eng4.sequent.com>

    Ben writes:

    > Amy writes:

    >> In MOOSE, I'm using hash tables for verb lookup for in-db parsing.
    >> I implemented this by having each hash slot be a property on the
    >> object.

    > If you don't like that, keep in mind that:
    >
    > 	object.(propname)
    >
    > is almost exactly the same as:
    >
    > 	values[propname in keys]

    ...right now, at least.

    > I would have to do some experiments to determine which one is faster,
    > but in most situations I would expect them to be very nearly equal.
    > Both are linear searches, of course,

    It will be a lot easier to make `object.(propname)' run faster than
    `values[propname in keys]', and there are plenty of incentives to
    expend effort there.  For that reason, I'd prefer the propname
    version.

    As Amy mentioned, keeping lists reasonably short is probably a good
    thing.  Somebody with more time for exposition for me should detail
    this.

    > but take advantage of the fact that it's a linear search in C code
    > rather than any other kind of search in MOO code.

    The other advantage that `object.(propname)' takes advantage of is
    that it will be working with relatively short string-valued keys; it
    can make sense to avoid strcmps by trying hashes first if strcmp isn't
    heavily optimized by your C compiler.  As Ben notes this clearly calls
    for experiment rather than guesses pulled out of a hat.
    --
    Jay Carlson    nop@nop.com    nop@kagoona.mitre.org

    Flat text is just *never* what you want.   ---stephen p spackman

Follow-Ups:

- Re: my kingdom for a hash table!

- From: "Robert J. Brown" <rj@eli.wariat.org>

References:

- Re: my kingdom for a hash table!

- From: Ben Jackson <bjj@sequent.com>

- Prev by Subject: Re: my kingdom for a hash table!
- Next by Subject: Re: my kingdom for a hash table!
- Prev by thread: Re: my kingdom for a hash table!
- Next by thread: Re: my kingdom for a hash table!
- Index(es):
  - Subject
  - Thread

Home | Subject Index | Thread Index