From: Tim Hunter Date: 2007-12-11T10:55:30+09:00 Subject: Re: Zero-copy String Handling Curt Sampson wrote: > On 2007-12-11 08:50 +0900 (Tue), Tim Hunter wrote: > >> For a problem of this scale, it seems like it would make sense to use a >> custom class that had some of the methods of String - enough for the >> callees to treat it like a String - but not in fact String. Give it a .to_s >> method to convert to a real String when it's really necessary. > > That's a good idea. In fact, I could use a struct of the same shape as > RString, and just invoke methods in string.c to do the real work for the > methods I decide to implement. I could also leave the objects existant > after the backing pages have been unmapped (as I do now with the String > objects), but tweak them so that they throw an exception when you try > to use them after that, as opposed to the current situation where the > interpreter dumps core. > > Thanks for the idea. > > cjs Works for me. RMagick 2 has the ability to "destroy" an image. A destroyed image is like a closed file. The object still exists but any attempt to use it raises a DestroyedImage exception. -- RMagick: http://rmagick.rubyforge.org/