From: | Aaron Optimizer Digulla |
Date: | 21 Sep 2000 at 08:55:42 |
Subject: | Re: AMIOPEN: Hotkey Config/Need suggestions |
On Wed, Sep 20, 2000 at 10:39:53PM -0700, Patrick Roberts wrote:
> I may have come up with a different solution though that uses checksums in
> the config file so the amount of memory used stays the same and lines can be in
> any order, plus have any sort of descriptor. I'm testing it now.
*Argh* Use hashes, man ! That's what they are for !! Check the Ami docs for
hash and atoms.
To explain: An atom maps a string to an integer. And a hash is a dictionary
where you can efficiently store values under keys and look them up later with
these keys. The code will look like this:
- Create a hash
- Register all config strings as atoms
- Use the IDs of the atoms to put the default values in the hash
- Read the config. Lookup the ids of the items and put them into
the hash.
- Later in the code, query the hash for the config items by using
the ids.
Simple, fast, efficient and most of the work has already been done by
Ami.