Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim Adcock) Newsgroups: comp.lang.c++ Subject: Re: class "names" at runtime (was Re: Design Problem) Message-ID: <10@microsoft.UUCP> Date: 19 Dec 89 00:00:15 GMT References: <22137@brunix.UUCP> <3164@cbnewsl.ATT.COM> <4329@pegasus.ATT.COM> Reply-To: jimad@microsoft.UUCP (Jim Adcock) Organization: Microsoft Corp., Redmond WA Lines: 11 One trick [from ObjC - gack!] is to maintain your names as pointers to strings to begin with, but when you access that pointer the first time you [automagically] change it to a handle for an entry in a lookup table. Since the table is a limited range of addresses, it is quick and easy to see if the conversion has already been done, and assuming it has been done, the comparison is just a pointer compare. Since the entry in the table is a string with the same characters, when you go back to a flat representation of your object, you automatically change it back to a string representation again. The cost is a couple extra pointer checks to see if the string is in the table [yet] or not. Alternately maintain a hash of the string and compare that.