[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Translator
Date: Fri, 14 Sep 90 10:59:53+0900
From: kddlab!atr-ln.atr.co.jp!myers@uunet.UU.NET (John K. Myers)
I'm building a rewriting system that takes a structure, looks at its
name, and calls a special rewriting function for it. The system has
to be blazingly fast. There will be about 1000 kinds of structures.
The question is how to rapidly associate a name with a rewriting function.
Three methods come immediately to mind:
1) Use a CASE on the names, to get to the functions;
2) Use the name as a key to a hash-table that stores the functions;
3) Use the name to build a function-name, using (intern (string-append )).
Then call the function using (apply func-name).
Even faster:
4. Use the name itself, assuming a symbol, as a function name. Then just
(funcall name)...
5. Keep the rewriting function in a slot of the structure, if it's not
too big a hassle. This takes the obvious extra storage.
6. Use a property on the name symbol and do GET on that.
If the names are not symbols, 2 is about the fastest, since 3 uses 2.
Eric C. Weaver
& Assocs. Inc.
Consultant
- References:
- Translator
- From: kddlab!atr-ln.atr.co.jp!myers@uunet.UU.NET (John K. Myers)