Prefer String#<< over += when possible

This commit is contained in:
Thomas Walpole 2018-11-19 15:44:51 -08:00
parent 8354eef965
commit 5a1b681253
2 changed files with 10 additions and 10 deletions

View File

@ -31,22 +31,22 @@ module Capybara
def split(css)
selectors = []
StringIO.open(css.to_s) do |str|
selector = ''
selector = +''
while (char = str.getc)
case char
when '['
selector += parse_square(str)
selector << parse_square(str)
when '('
selector += parse_paren(str)
selector << parse_paren(str)
when '"', "'"
selector += parse_string(char, str)
selector << parse_string(char, str)
when '\\'
selector += char + str.getc
selector << char + str.getc
when ','
selectors << selector.strip
selector = ''
selector.clear
else
selector += char
selector << char
end
end
selectors << selector.strip

View File

@ -40,9 +40,9 @@ module Capybara
def description(node_filters: true, expression_filters: true, **options)
opts = options_with_defaults(options)
description = +''
description += undeclared_descriptions.map { |desc| desc.call(opts).to_s }.join
description += expression_filter_descriptions.map { |desc| desc.call(opts).to_s }.join if expression_filters
description += node_filter_descriptions.map { |desc| desc.call(opts).to_s }.join if node_filters
description << undeclared_descriptions.map { |desc| desc.call(opts).to_s }.join
description << expression_filter_descriptions.map { |desc| desc.call(opts).to_s }.join if expression_filters
description << node_filter_descriptions.map { |desc| desc.call(opts).to_s }.join if node_filters
description
end