ruby-changes:59304
From: Kazuhiro <ko1@a...>
Date: Tue, 17 Dec 2019 21:56:36 +0900 (JST)
Subject: [ruby-changes:59304] 299db37957 (master): Use while instead of loop
https://git.ruby-lang.org/ruby.git/commit/?id=299db37957 From 299db379575da122bc20745811fc1e20ba01f3ce Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA <zn@m...> Date: Tue, 17 Dec 2019 09:46:45 +0900 Subject: Use while instead of loop diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index b20f84b..2b7d19a 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -631,9 +631,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L631 with_binary(true) do begin conn = transfercmd(cmd, rest_offset) - loop do - data = conn.read(blocksize) - break if data == nil + while data = conn.read(blocksize) yield(data) end conn.shutdown(Socket::SHUT_WR) @@ -658,9 +656,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L656 with_binary(false) do begin conn = transfercmd(cmd) - loop do - line = conn.gets - break if line == nil + while line = conn.gets yield(line.sub(/\r?\n\z/, ""), !line.match(/\n\z/).nil?) end conn.shutdown(Socket::SHUT_WR) @@ -688,9 +684,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L684 with_binary(true) do begin conn = transfercmd(cmd) - loop do - buf = file.read(blocksize) - break if buf == nil + while buf = file.read(blocksize) conn.write(buf) yield(buf) if block_given? end @@ -723,9 +717,7 @@ module Net https://github.com/ruby/ruby/blob/trunk/lib/net/ftp.rb#L717 with_binary(false) do begin conn = transfercmd(cmd) - loop do - buf = file.gets - break if buf == nil + while buf = file.gets if buf[-2, 2] != CRLF buf = buf.chomp + CRLF end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/