Ruby mogilefs-client dev/users discussion/patches/bugs/help/...
 help / color / mirror / code / Atom feed
* [PATCH 0/3] minor updates and cleanups
@ 2015-09-14 10:24 Eric Wong
  2015-09-14 10:24 ` [PATCH 1/3] admin: simplify utilization conversion Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2015-09-14 10:24 UTC (permalink / raw)
  To: mogilefs-client-public

3/3 is an actual bugfix, so I'll likely release 3.10.0 soon
for it.  The rest are stylistic changes.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] admin: simplify utilization conversion
  2015-09-14 10:24 [PATCH 0/3] minor updates and cleanups Eric Wong
@ 2015-09-14 10:24 ` Eric Wong
  2015-09-14 10:24 ` [PATCH 2/3] more idiomatic comparisons with constants Eric Wong
  2015-09-14 10:24 ` [PATCH 3/3] bigfile/filter: only update MD5 if non-nil Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2015-09-14 10:24 UTC (permalink / raw)
  To: mogilefs-client-public; +Cc: Eric Wong

The tracker won't send a utilization field until it has
that data.
---
 lib/mogilefs/admin.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/mogilefs/admin.rb b/lib/mogilefs/admin.rb
index 68574ca..289dea6 100644
--- a/lib/mogilefs/admin.rb
+++ b/lib/mogilefs/admin.rb
@@ -69,8 +69,7 @@ class MogileFS::Admin < MogileFS::Client
     rv = clean('devices', 'dev', rv, true, to_i, want)
 
     rv.each do |row|
-      u = row["utilization"] and
-        row["utilization"] = nil == u ? nil : u.to_f
+      u = row["utilization"] and row["utilization"] = u.to_f
 
       case row["observed_state"]
       when ""
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] more idiomatic comparisons with constants
  2015-09-14 10:24 [PATCH 0/3] minor updates and cleanups Eric Wong
  2015-09-14 10:24 ` [PATCH 1/3] admin: simplify utilization conversion Eric Wong
@ 2015-09-14 10:24 ` Eric Wong
  2015-09-14 10:24 ` [PATCH 3/3] bigfile/filter: only update MD5 if non-nil Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2015-09-14 10:24 UTC (permalink / raw)
  To: mogilefs-client-public; +Cc: Eric Wong

These generates smaller bytecode than explicitly
comparing to a constant value.
---
 lib/mogilefs/bigfile/filter.rb  | 2 +-
 lib/mogilefs/new_file/stream.rb | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/mogilefs/bigfile/filter.rb b/lib/mogilefs/bigfile/filter.rb
index e95a47e..d831312 100644
--- a/lib/mogilefs/bigfile/filter.rb
+++ b/lib/mogilefs/bigfile/filter.rb
@@ -33,7 +33,7 @@ class MogileFS::Bigfile::Filter
   end
 
   def write(buf)
-    if nil == @zi
+    unless @zi
       if @info[:compressed] &&
          INFLATABLE_TYPES.include?(@info[:type]) &&
          buf.bytesize >= 2 &&
diff --git a/lib/mogilefs/new_file/stream.rb b/lib/mogilefs/new_file/stream.rb
index a71be74..71ac591 100644
--- a/lib/mogilefs/new_file/stream.rb
+++ b/lib/mogilefs/new_file/stream.rb
@@ -42,7 +42,7 @@ class MogileFS::NewFile::Stream
 
   def write(buf)
     buf = String buf
-    return 0 if 0 == buf.size
+    return 0 if buf.empty?
     rv = @writer.write(buf)
     @bytes_uploaded += rv
     rv
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] bigfile/filter: only update MD5 if non-nil
  2015-09-14 10:24 [PATCH 0/3] minor updates and cleanups Eric Wong
  2015-09-14 10:24 ` [PATCH 1/3] admin: simplify utilization conversion Eric Wong
  2015-09-14 10:24 ` [PATCH 2/3] more idiomatic comparisons with constants Eric Wong
@ 2015-09-14 10:24 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2015-09-14 10:24 UTC (permalink / raw)
  To: mogilefs-client-public; +Cc: Eric Wong

It is possible to disable MD5 verification, so we cannot risk
updating a nil object.

Also, favor explicitly calling "update" instead of using "<<" which
YARV will attempt to optimize for Array/String receivers at the cost
of other objects (such as Digest::MD5)
---
 lib/mogilefs/bigfile/filter.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/mogilefs/bigfile/filter.rb b/lib/mogilefs/bigfile/filter.rb
index d831312..e3b6874 100644
--- a/lib/mogilefs/bigfile/filter.rb
+++ b/lib/mogilefs/bigfile/filter.rb
@@ -51,7 +51,7 @@ class MogileFS::Bigfile::Filter
     if @zi
       buf = @zi.inflate(buf)
     else
-      @md5 << buf
+      @md5.update(buf) if @md5
     end
     @io.write(buf)
   end
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-14 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-14 10:24 [PATCH 0/3] minor updates and cleanups Eric Wong
2015-09-14 10:24 ` [PATCH 1/3] admin: simplify utilization conversion Eric Wong
2015-09-14 10:24 ` [PATCH 2/3] more idiomatic comparisons with constants Eric Wong
2015-09-14 10:24 ` [PATCH 3/3] bigfile/filter: only update MD5 if non-nil 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).