From c32f1d06e0c82c09f79fa61447e1acb6b900e84e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 28 May 2015 19:01:35 +0000 Subject: avoid defineclass instructions for empty classes This needlessly wastes bytecode and saves around 2K memory on 64-bit platforms. --- lib/mogilefs.rb | 20 ++++++++++---------- lib/mogilefs/util.rb | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/mogilefs.rb b/lib/mogilefs.rb index 6059836..cf6b5df 100644 --- a/lib/mogilefs.rb +++ b/lib/mogilefs.rb @@ -16,18 +16,18 @@ module MogileFS end # Standard error class for most MogileFS-specific errors - class Error < StandardError; end + Error = Class.new(StandardError) # Raised when a socket remains unreadable for too long. - class UnreadableSocketError < Error; end + UnreadableSocketError = Class.new(Error) # Raised when a response is truncated while reading # due to network/server # errors) - class SizeMismatchError < Error; end + SizeMismatchError = Class.new(Error) # Raised when checksum verification fails (only while reading deprecated # "bigfiles" from the deprecated mogtool(1). - class ChecksumMismatchError < RuntimeError; end + ChecksumMismatchError = Class.new(RuntimeError) # Raised when a backend is in read-only mode class ReadOnlyError < Error @@ -37,27 +37,27 @@ module MogileFS end # Raised when an upload is impossible - class EmptyPathError < Error; end + EmptyPathError = Class.new(Error) # Raised when we are given an unsupported protocol to upload to. # Currently, the \MogileFS (2.XX) server only supports HTTP and # this library is only capable of HTTP. - class UnsupportedPathError < Error; end + UnsupportedPathError = Class.new(Error) # Raised when a request (HTTP or tracker) was truncated due to a network or # server error. It may be possible to retry idempotent requests from this. - class RequestTruncatedError < Error; end + RequestTruncatedError = Class.new(Error) # Raised when a response from a server (HTTP or tracker) is not in a format # that we expected (or truncated.. - class InvalidResponseError < Error; end + InvalidResponseError = Class.new(Error) # Raised when all known backends have failed. - class UnreachableBackendError < Error; end + UnreachableBackendError = Class.new(Error) # There was an error as a result of the use of the (experimental) # pipelining code to the tracker backend - class PipelineError < Error; end + PipelineError = Class.new(Error) # :stopdoc: class << self diff --git a/lib/mogilefs/util.rb b/lib/mogilefs/util.rb index 6277497..ad4845d 100644 --- a/lib/mogilefs/util.rb +++ b/lib/mogilefs/util.rb @@ -24,4 +24,4 @@ require 'timeout' # Timeout error class. Subclassing it from Timeout::Error is the only # reason we require the 'timeout' module, otherwise that module is # broken and worthless to us. -class MogileFS::Timeout < Timeout::Error; end +MogileFS::Timeout = Class.new(Timeout::Error) -- cgit v1.2.3-24-ge0c7