Ruby mogilefs-client dev/users discussion/patches/bugs/help/...
 help / color / mirror / code / Atom feed
* [PATCH] avoid defineclass instructions for empty classes
@ 2015-05-28 19:04 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-05-28 19:04 UTC (permalink / raw)
  To: mogilefs-client-public; +Cc: Eric Wong

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 @@ def self.now
   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 @@ def message # :nodoc:
   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 @@ def length
 # 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)
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-28 19:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-28 19:04 [PATCH] avoid defineclass instructions for empty classes Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/mogilefs-client.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).