On Thu, Jan 15, 2004 at 06:27:52PM -0500, Melvin Smith wrote: > At 06:13 PM 1/15/2004 -0500, Melvin Smith wrote: > >At 10:02 PM 1/15/2004 +0100, Elizabeth Mattijsen wrote: > >>At 15:51 -0500 1/15/04, Melvin Smith wrote: > >>>Comments & questions welcome. > >> > >>Why am I thinking of the "register" keyword in C? > > > >I have no idea and I can't see the relationship. :) > > I just realized my response sounded crass, and wasn't meant to be. > I welcome comments, I just didn't understand what relation > you were getting at. Feel free to point it out to me. > > The context: Jonathan was asking about importing > constants at runtime and/or constant namespaces. > > Dan and I were discussing the issues and how routines > with lots of package globals or constants would spend > a significant part of their time retrieving symbols. Jonathan > did not want compile time constants, Dan did not want > "importable" constants that mutate the bytecode at runtime, > so I was trying to come up with a compromise, ugly as > it may be.
Aren't constant strings going to be saved in a way that lets the address of the saved string be used to avoid string comparisons? (As is done for hash keys in perl5.) Perhaps that's already done. Then bytecode could 'declare' all the string constants it contains. The byteloader could merge them into the global saved strings pool and 'fixup' references to them in the bytecode. If the namespace lookup code knew when it was being given saved string pointers it could avoid the string compares as it walks the namespace tree. Maybe all that's been done. Here's an idea that builds on that: Perhaps a variant of a hash that worked with large integers (pointers) as keys could be of some use here. The namespace could be a tree of these 'integer hashes'. Most namespace lookups use constants which can be 'registered' in the unique string pool at byteloader time. To lookup a non-constant string you just need to check if it's in the unique string pool and get that pointer if it is. If it's not then you know it doesn't exist anywhere. If it is you do the lookup using the address of the string in the pool. The JudyL functions (http://judy.sourceforge.net/) provide a very efficient 'integer hash'. Tim.