Skip to content

Commit c8ae854

Browse files
committed
Split internal strscan method into multiple parts for better inlining.
1 parent 8ede413 commit c8ae854

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/truffle/strscan.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,23 @@ def peep(len)
308308
peek len
309309
end
310310

311-
def scan_internal(pattern, advance_pos, getstr, headonly)
311+
def scan_check_args(pattern, headonly)
312312
unless pattern.kind_of? Regexp
313313
raise TypeError, "bad pattern argument: #{pattern.inspect}"
314314
end
315315
raise ArgumentError, 'uninitialized StringScanner object' unless @string
316+
end
317+
318+
def scan_internal(pattern, advance_pos, getstr, headonly)
319+
scan_check_args(pattern, headonly)
316320

317321
md = Truffle::RegexpOperations.match_in_region pattern, @string, pos, @string.bytesize, headonly, pos
318322
Primitive.matchdata_fixup_positions(md, pos) if md
319323
@match = md
324+
scan_internal2(advance_pos, getstr)
325+
end
326+
327+
def scan_internal2(advance_pos, getstr)
320328
return nil unless @match
321329

322330
fin = Primitive.match_data_byte_end(@match, 0)
@@ -329,6 +337,6 @@ def scan_internal(pattern, advance_pos, getstr, headonly)
329337

330338
@string.byteslice(@prev_pos, width)
331339
end
332-
private :scan_internal
340+
private :scan_internal, :scan_internal2, :scan_check_args
333341

334342
end

0 commit comments

Comments
 (0)