Skip to content

Conversation

@etiennebarrie
Copy link
Contributor

#14 is causing a warning under Ruby 2.7 when the instance variable is first used without having been initialized first.

I know this warning has been removed since Ruby 3.0, but with object shapes coming up it might be good anyway to make sure all instances share all the same shape transitions that way none of the instance variable reads will get cache misses.

@hsbt
Copy link
Member

hsbt commented Dec 7, 2022

Thanks for your report. Can you show the warnings with Ruby 2.7? I will merge this after it.

@etiennebarrie
Copy link
Contributor Author

Of course. The test case causes the warning under Ruby 2.7 without the added line in the initializer. You can also see that with the released version like this:

echo | ruby -v \
  -e 'gem "net-protocol", "0.2.0"' \
  -e 'require "net/protocol"' \
  -e 'puts Net::Protocol::VERSION' \
  -e 'Net::BufferedIO.new(STDIN).readline'
ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [arm64-darwin21]
0.2.0
/Users/etienne/.gem/ruby/2.7.7/gems/net-protocol-0.2.0/lib/net/protocol.rb:216: warning: instance variable @rbuf_empty not initialized

@hsbt
Copy link
Member

hsbt commented Dec 7, 2022

Thanks a lot. This fix seems reasonable.

@hsbt hsbt merged commit 735c047 into ruby:master Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants