File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ def read_ber syntax=nil
9494 end
9595 }
9696
97+ =begin
98+ Replaced this case with if/else because Symbol#=== profiled surprisingly hot.
9799 obj = case objtype
98100 when :boolean
99101 newobj != "\000"
@@ -116,6 +118,29 @@ def read_ber syntax=nil
116118 else
117119 raise BerError.new( "unsupported object type: class=#{tagclass}, encoding=#{encoding}, tag=#{tag}" )
118120 end
121+ =end
122+
123+ obj = if objtype == :boolean
124+ newobj != "\000 "
125+ elsif objtype == :string
126+ ( newobj || "" ) . dup
127+ elsif objtype == :integer
128+ j = 0
129+ newobj . each_byte { |b | j = ( j << 8 ) + b }
130+ j
131+ elsif objtype == :array
132+ seq = [ ]
133+ sio = StringIO . new ( newobj || "" )
134+ # Interpret the subobject, but note how the loop
135+ # is built: nil ends the loop, but false (a valid
136+ # BER value) does not!
137+ while ( e = sio . read_ber ( syntax ) ) != nil
138+ seq << e
139+ end
140+ seq
141+ else
142+ raise BerError . new ( "unsupported object type: class=#{ tagclass } , encoding=#{ encoding } , tag=#{ tag } " )
143+ end
119144
120145 # Add the identifier bits into the object if it's a String or an Array.
121146 # We can't add extra stuff to Fixnums and booleans, not that it makes much sense anyway.
You can’t perform that action at this time.
0 commit comments