lib/taskjuggler/DataCache.rb in taskjuggler-0.0.11 vs lib/taskjuggler/DataCache.rb in taskjuggler-0.1.0

- old
+ new

@@ -97,10 +97,25 @@ @entries[key] = DataCacheEntry.new(value) value end + if RUBY_VERSION < '1.9.0' + + # Ruby 1.8 has a buggy hash key generation algorithm that leads to many + # hash collisions. We completely disable caching on 1.8. + + def load(key) + nil + end + + def cached(key) + yield + end + + else + # Retrieve the value indexed by _key_ from the cache. If it's not found, # nil is returned. def load(key) if (e = @entries[key]) @hits += 1 @@ -121,9 +136,11 @@ else @misses += 1 store(yield, key) end end + + end def to_s <<"EOT" Entries: #{@entries.size} Stores: #{@stores} Hits: #{@hits} Misses: #{@misses}