From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-04-08T12:52:21+09:00 Subject: Re: [embedding] keeping track of non-exported global variables On Tue, 08 Apr 2003 12:33:38 +0900, nobu.nokad wrote: > Hi, > > At Tue, 8 Apr 2003 02:49:23 +0900, > Simon Strandgaard wrote: >> Arrays works fine for me, but im still wondering why >> both mod_ruby, vim, ruby++ uses hashes ??? >> It seems odd. > > I don't know true reason, but I kind of guess it's because > removing an object from a hash is faster than an array when > they have many elements. I've checked ruby-1.8.0's array.c/rb_ary_delete and hash.c/rb_hash_delete. The for loop in Array.delete appears to iterate throught the whole array [linear time]. The Hash.delete doesn't have any loops [constant time] :-) Argh!! I now see why they all are using hashes. This problem is now solved, thanks. >> Objects::~Objects() { >> /* flush array in order to kill em >> I do not think this is necessary at all. >> I am assuming that calling ruby_finalize() >> would effectivly kill all! >> todo: is flushing necessary? */ >> } > > Registered variable must not contain invalid VALUE - other than > object, Fixnum, Symbol, true, false and nil. If you're really > sure that any "Objects" instances never get destructed until > ruby_finalize(), it would not be necessary. Otherwise, it > causes GC crashes at high possibility. Sorry I don't understand, can you rephrase it ??? Yes, cleanup must be correct :-) -- Simon Strandgaard