This commit moves all struct array-ish calls to use their method calls instead. It is also ~1.23 faster accessing values via a method instead of as an array according to this microbenchmark:
Elem=Struct.new(:pos,:event,:tok,:state,:message)dodefinitialize(pos,event,tok,state,message=nil)super(pos,event,tok,State.new(state),message)end# ...defto_aa=supera.popunlessa.empty?aendendclassElemClassattr_accessor:pos,:event,:tok,:state,:messagedefinitialize(pos,event,tok,state,message=nil)@pos=pos@event=event@tok=tok@state=State.new(state)@message=messageenddefto_aif@message[@pos,@event,@tok,@state,@message]else[@pos,@event,@tok,@state]endendend# stub state class creation for nowclassState;definitialize(val);end;end
Compatibility with IRB
Instead of accessing the struct as an array, access it via methods. There are other places inside of this file already using this API (for example https://github.com/ruby/ruby/blob/e0a5c3d2b71dfad038d7562fdd33f02ffd79232d/lib/irb/ruby-lex.rb#L829-L830).
This commit moves all struct array-ish calls to use their method calls instead. It is also ~1.23 faster accessing values via a method instead of as an array according to this microbenchmark: