Skip to content

Commit

Permalink
Refactor buffer usage to only use append_as_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Jan 7, 2025
1 parent 910e6ab commit 2879f43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/openssl/buffering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def append_as_bytes(string)
end
end

alias_method :concat, :append_as_bytes
alias_method :<<, :append_as_bytes
undef_method :concat
undef_method :<<
end

##
Expand Down Expand Up @@ -73,7 +73,7 @@ def initialize(*)

def fill_rbuff
begin
@rbuffer << self.sysread(BLOCK_SIZE)
@rbuffer.append_as_bytes(self.sysread(BLOCK_SIZE))
rescue Errno::EAGAIN
retry
rescue EOFError
Expand Down Expand Up @@ -450,10 +450,10 @@ def <<(s)
def puts(*args)
s = Buffer.new
if args.empty?
s << "\n"
s.append_as_bytes("\n")
end
args.each{|arg|
s << arg.to_s
s.append_as_bytes(arg.to_s)
s.sub!(/(?<!\n)\z/, "\n")
}
do_write(s)
Expand All @@ -467,7 +467,7 @@ def puts(*args)

def print(*args)
s = Buffer.new
args.each{ |arg| s << arg.to_s }
args.each{ |arg| s.append_as_bytes(arg.to_s) }
do_write(s)
nil
end
Expand Down
2 changes: 1 addition & 1 deletion test/openssl/test_buffering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def sysread(size)
end

def syswrite(str)
@io << str
@io.append_as_bytes(str)
str.size
end
end
Expand Down

0 comments on commit 2879f43

Please sign in to comment.