On 22 Sep, Chris Kuklewicz wrote:
> Have a hash_set<char*> which holds new refcount 1 strings (and thus
> has no int overhead), and a hash_map<char*, unsigned int> which holds
> any refcount string. A duplicate has to be searched for in both the
> hash_map and hash_set when adding a new string. When ++refcount on
> char* in the hash_set, move char* to the hash_map with refcount 2.
> Note: If the stored refcount in hash_map is zero, it means the string
> is static and need never be freed, and the refcount stays at zero.
> When --refcount, do not move char* back from hash_map to hash_set,
> just leave it in hash_set with a refcount of 1.
Interesting idea -- do you know how much memory overhead there is for a
hash_map? I really like the not duplicating strings -- in the case of
the data that we're throwing at it that would be a good way to save
memory.
Would you be interested in hacking on this?
>> The only outside code change that needs to happen is that when someone
>> creates a metadata/playlist object, the freestore pointer needs to get
>> passed in.
>
> Hmmm....here you seem to want the context (which is currently
> singular?) to not be a guaranteed singleton. But the freestore could
> be a singleton, why not? Then you could access it without needing to
> pass its address to MetaData/PlaylistItem every single time.
>
> ---
>
> A wierd hack, but space efficient. Note that the size of each
> album_key instance is only the size of one char*. Besides, no
> hairbrained amateur scheme in C++ is complete without a YASPC (yet
> another smart pointer class).
>
> extern freestore& get_album_freestore(); // Global function or method of singleton.
The only problem is that global functions are not global under windows
across DLL boundaries. While DLLs get mapped into the same address
space, globals/global functions are not visible unless explicitly
exported. We could pass this in as part of the initialization of each of
the plugin DLLS, but that's kinda ugly and a pain too.
--ruaok Freezerburn! All else is only icing. -- Soul Coughing
Robert Kaye -- [EMAIL PROTECTED] http://moon.eorbit.net/~robert
_______________________________________________
[EMAIL PROTECTED]
http://www.freeamp.org/mailman/listinfo/freeamp-dev