It depends on what "internal" you say. There are 7 Ruby-ready implementations in current use, and the Ruby language specification does not prescribe any particular algorithm. So it really depends on the implementation.
For example, this Rubinius implementation uses :
Rubinius.check_frozen if block_given? im = Rubinius::IdentityMap.from(self, &block) else im = Rubinius::IdentityMap.from(self) end return if im.size == size array = im.to_array @tuple = array.tuple @start = array.start @total = array.total self
And this is one from JRuby :
RubyHash hash = makeHash(); if (realLength == hash.size()) return makeShared(); RubyArray result = new RubyArray(context.runtime, getMetaClass(), hash.size()); int j = 0; try { for (int i = 0; i < realLength; i++) { IRubyObject v = elt(i); if (hash.fastDelete(v)) result.values[j++] = v; } } catch (ArrayIndexOutOfBoundsException aioob) { concurrentModification(); } result.realLength = j; return result;
JΓΆrg W Mittag
source share