diff options
author | Eric Wong <e@yhbt.net> | 2011-01-17 03:20:01 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-01-17 09:18:31 +0000 |
commit | 34a18520286313a05edc9a927ac4bed95b05191c (patch) | |
tree | c95c6254da91571e2dffa99f6cb03b9e904fe411 | |
parent | 3f821a4cb7b50e542dd7828d1e507b76e18ecfb5 (diff) | |
download | metropolis-34a18520286313a05edc9a927ac4bed95b05191c.tar.gz |
tdb: use fetch with a reusable buffer
GC reductions
-rw-r--r-- | lib/metropolis/tdb.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/metropolis/tdb.rb b/lib/metropolis/tdb.rb index dac613d..5621d17 100644 --- a/lib/metropolis/tdb.rb +++ b/lib/metropolis/tdb.rb @@ -9,6 +9,7 @@ module Metropolis::TDB def setup(opts) super + @rbuf = "" @tdb_opts = { :tdb_flags => 0 } if @readonly @tdb_opts[:open_flags] = IO::RDONLY @@ -62,7 +63,7 @@ module Metropolis::TDB end def get(key, env) - value = db(key) { |tdb| tdb.fetch(key) } or return r(404) + value = db(key) { |tdb| tdb.fetch(key, @rbuf) } or return r(404) [ 200, { 'Content-Length' => value.size.to_s }.merge!(@headers), [ value ] ] end end |