On Wed, Aug 8, 2007 at 9:17 AM, via RT chromatic <[EMAIL PROTECTED]> wrote:
> Another option is to cache the C string in the STRING structure itself in the > same way that Perl 5 caches IVs and NVs and PVs in the SV structure. (If > that doesn't mean anything to you, congratulations. I have this little > throbbing right behind my left eyeball just typing that.) The attached patch uses a new function, Parrot_string_get_cstring, to obtain a C string owned and cached by the parrot string, that lives while the parrot string is not modified, the function Parrot_string_free_cstring to delete the C string, intended only for internal usage, adds the cstring_val member to the parrot string struct to store the cached C string, and uses it in several places to avoid string_to_cstring usage and some potential bugs related to it. It uses string_to_cstring and string_cstring_free to implement these new functions. It also fills with garbage the C string in string_cstring_free, to help catch errors of using a C string after freeing it. -- Salu2