Skip to content

Commit

Permalink
Use /#{Regexp.escape}/ instead of Regexp.union
Browse files Browse the repository at this point in the history
It's for readability.
  • Loading branch information
kou committed May 30, 2024
1 parent f1df7d1 commit f525ef7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rexml/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def read(term = nil)
end

def read_until(term)
@scanner.scan_until(Regexp.union(term)) or @scanner.rest
@scanner.scan_until(/#{Regexp.escape(term)}/) or @scanner.rest
end

def ensure_buffer
Expand Down Expand Up @@ -173,7 +173,7 @@ def read(term = nil)
end

def read_until(term)
pattern = Regexp.union(term)
pattern = /#{Regexp.escape(term)}/
begin
until str = @scanner.scan_until(pattern)
@scanner << readline(term)
Expand Down

0 comments on commit f525ef7

Please sign in to comment.