Skip to content

Commit

Permalink
Remove unnecessary checks in baseparser (#112)
Browse files Browse the repository at this point in the history
## Why


https://github.com/ruby/rexml/blob/444c9ce7449d3c5a75ae50087555ec73ae1963a8/lib/rexml/parsers/baseparser.rb#L352-L425
```
          next_data = @source.buffer
          if next_data.size < 2
            @source.read
            next_data = @source.buffer
          end
          if next_data[0] == ?<
              :
            (omit)
              :
          else # next_data is a string of one or more characters other than '<'.
            md = @source.match( TEXT_PATTERN, true ) # TEXT_PATTERN = /\A([^<]*)/um
            text = md[1]
            if md[0].length == 0 # md[0].length is greater than or equal to 1.
              @source.match( /(\s+)/, true )
            end
```
This is an unnecessary check because md[0].length is greater than or
equal to 1.
  • Loading branch information
naitoh authored Feb 15, 2024
1 parent 444c9ce commit fc6cad5
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lib/rexml/parsers/baseparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,6 @@ def pull_event
else
md = @source.match( TEXT_PATTERN, true )
text = md[1]
if md[0].length == 0
@source.match( /(\s+)/, true )
end
return [ :text, text ]
end
rescue REXML::UndefinedNamespaceException
Expand Down

0 comments on commit fc6cad5

Please sign in to comment.