Skip to content

Commit

Permalink
Change @scanner.match to respond nil/@scanner in order to impro…
Browse files Browse the repository at this point in the history
…ve processing speed.
  • Loading branch information
naitoh committed Jan 14, 2024
1 parent 1b435a0 commit ec62e37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/rexml/parsers/baseparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ def pull_event
return [ :elementdecl, @source.match( ELEMENTDECL_PATTERN, true )[1] ]

when ENTITY_START
match = @source.match( ENTITYDECL, true ).compact
match[0] = :entitydecl
match = @source.match( ENTITYDECL, true )
match = match.nil? ? [:entitydecl] : [:entitydecl, *match.captures.compact]
ref = false
if match[1] == '%'
ref = true
Expand Down
4 changes: 2 additions & 2 deletions lib/rexml/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def match(pattern, cons=false)
else
@scanner.check(pattern)
end
@scanner.matched? ? [@scanner.matched, *@scanner.captures] : nil
@scanner.matched? ? @scanner : nil
end

# @return true if the Source is exhausted
Expand Down Expand Up @@ -175,7 +175,7 @@ def match( pattern, cons=false )
end
end

@scanner.matched? ? [@scanner.matched, *@scanner.captures] : nil
@scanner.matched? ? @scanner : nil
end

def empty?
Expand Down

0 comments on commit ec62e37

Please sign in to comment.