diff options
author | Eric Wong <e@80x24.org> | 2015-04-07 20:22:53 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-04-07 20:24:37 +0000 |
commit | f1734dc1281de6c8c1f57ab798498cdf78967d75 (patch) | |
tree | 79079df9d6d8317455a954d21947fc52ff7153ed /lib/yahns/tmpio.rb | |
parent | 9ae8745eb06cd601d5c1f56eb1e3c4b0678508f8 (diff) | |
download | yahns-f1734dc1281de6c8c1f57ab798498cdf78967d75.tar.gz |
Instance variable attr methods are cheaper and we can shove the complexity down to tmpio by allowing it to accept a nil argument for the temporary directory. This adds 4 bytes to tmpio but removes over 1K in http_context on a 32-bit system.
Diffstat (limited to 'lib/yahns/tmpio.rb')
-rw-r--r-- | lib/yahns/tmpio.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/yahns/tmpio.rb b/lib/yahns/tmpio.rb index d25d5e8..ca86b4e 100644 --- a/lib/yahns/tmpio.rb +++ b/lib/yahns/tmpio.rb @@ -12,10 +12,10 @@ class Yahns::TmpIO < File # :nodoc: # creates and returns a new File object. The File is unlinked # immediately, switched to binary mode, and userspace output # buffering is disabled - def self.new(tmpdir = Dir.tmpdir) + def self.new(dir) retried = false begin - fp = super("#{tmpdir}/#{rand}", RDWR|CREAT|EXCL|APPEND, 0600) + fp = super("#{dir || Dir.tmpdir}/#{rand}", RDWR|CREAT|EXCL|APPEND, 0600) rescue Errno::EEXIST retry rescue Errno::EMFILE, Errno::ENFILE |