On Dec 29, 2010, at 12:36 PM, Alan Post wrote:
On Wed, Dec 29, 2010 at 11:31:28AM -0600, mikel evins wrote:
The application I'm working on marshals a large number of strings across the FFI boundary. Large enough, in fact, that I've periodically considered introducing some interning strategy to ensure that a given character sequence is marshaled across the FFI at most once.
If you have any ideas that might make such a scheme easier to implement, I'd be interested in hearing them.
My first though, in reading this, is that you want to intern the longest repeated substring on each side. A trie structure can compute this sort of information, and your marshall protocol might be something you could express as updates to a trie synced on both sides, rather than marshalling strings.
If that is interesting enough where you'd like more detail, just ask and I'll keep talking. If it isn't applicable to your idea, hopefully someone else will come up with something better!
Actually, no need; I know how tries work. That's not a bad idea; I'll give it some thought.
--me