Skip to content

Commit 7369daa

Browse files
makenowjustasterite
authored andcommitted
MatchData: refactor to_s
1 parent 203ab9f commit 7369daa

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/regex/match_data.cr

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,11 @@ class Regex
295295
def to_s(io : IO)
296296
name_table = @regex.name_table
297297

298-
io << "#<Regex::MatchData "
299-
self[0].inspect(io)
300-
if size > 1
298+
io << "#<Regex::MatchData"
299+
size.times do |i|
301300
io << " "
302-
(1...size).join " ", io do |i|
303-
io << name_table.fetch(i) { i }
304-
io << ":"
305-
self[i]?.inspect(io)
306-
end
301+
io << name_table.fetch(i) { i } << ":" if i > 0
302+
self[i]?.inspect(io)
307303
end
308304
io << ">"
309305
end

0 commit comments

Comments
 (0)