Skip to content

Commit 78a88ab

Browse files
committed
Eagerly split StringScanner methods doing a Regexp match
1 parent 940a91d commit 78a88ab

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/truffle/strscan.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ def charpos
9999
def check(pattern)
100100
scan_internal pattern, false, true, true
101101
end
102+
Primitive.always_split self, :check
102103

103104
def check_until(pattern)
104105
scan_internal pattern, false, true, false
105106
end
107+
Primitive.always_split self, :check_until
106108

107109
def clear
108110
warn 'StringScanner#clear is obsolete; use #terminate instead' if $VERBOSE
@@ -128,6 +130,7 @@ def eos?
128130
def exist?(pattern)
129131
scan_internal pattern, false, false, false
130132
end
133+
Primitive.always_split self, :exist?
131134

132135
def fixed_anchor?
133136
@fixed_anchor
@@ -192,6 +195,7 @@ def inspect
192195
def match?(pattern)
193196
scan_internal pattern, false, false, true
194197
end
198+
Primitive.always_split self, :match?
195199

196200
def matched
197201
@match&.to_s
@@ -247,6 +251,7 @@ def restsize
247251
def scan(pattern)
248252
scan_internal pattern, true, true, true
249253
end
254+
Primitive.always_split self, :scan
250255

251256
def scan_byte
252257
if eos?
@@ -284,14 +289,17 @@ def scan_integer(base: 10)
284289
def scan_until(pattern)
285290
scan_internal pattern, true, true, false
286291
end
292+
Primitive.always_split self, :scan_until
287293

288294
def scan_full(pattern, advance_pos, getstr)
289295
scan_internal pattern, advance_pos, getstr, true
290296
end
297+
Primitive.always_split self, :scan_full
291298

292299
def search_full(pattern, advance_pos, getstr)
293300
scan_internal pattern, advance_pos, getstr, false
294301
end
302+
Primitive.always_split self, :search_full
295303

296304
def self.must_C_version
297305
self
@@ -304,10 +312,12 @@ def size
304312
def skip(pattern)
305313
scan_internal pattern, true, false, true
306314
end
315+
Primitive.always_split self, :skip
307316

308317
def skip_until(pattern)
309318
scan_internal pattern, true, false, false
310319
end
320+
Primitive.always_split self, :skip_until
311321

312322
def string
313323
@original
@@ -387,6 +397,7 @@ def peep(len)
387397
@match = nil
388398
end
389399
end
400+
Primitive.always_split self, :scan_internal
390401

391402
private def scan_internal_string_pattern(pattern, headonly)
392403
pos = @pos

0 commit comments

Comments
 (0)