Prefer String#<< over += when possible
This commit is contained in:
parent
8354eef965
commit
5a1b681253
|
@ -31,22 +31,22 @@ module Capybara
|
||||||
def split(css)
|
def split(css)
|
||||||
selectors = []
|
selectors = []
|
||||||
StringIO.open(css.to_s) do |str|
|
StringIO.open(css.to_s) do |str|
|
||||||
selector = ''
|
selector = +''
|
||||||
while (char = str.getc)
|
while (char = str.getc)
|
||||||
case char
|
case char
|
||||||
when '['
|
when '['
|
||||||
selector += parse_square(str)
|
selector << parse_square(str)
|
||||||
when '('
|
when '('
|
||||||
selector += parse_paren(str)
|
selector << parse_paren(str)
|
||||||
when '"', "'"
|
when '"', "'"
|
||||||
selector += parse_string(char, str)
|
selector << parse_string(char, str)
|
||||||
when '\\'
|
when '\\'
|
||||||
selector += char + str.getc
|
selector << char + str.getc
|
||||||
when ','
|
when ','
|
||||||
selectors << selector.strip
|
selectors << selector.strip
|
||||||
selector = ''
|
selector.clear
|
||||||
else
|
else
|
||||||
selector += char
|
selector << char
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
selectors << selector.strip
|
selectors << selector.strip
|
||||||
|
|
|
@ -40,9 +40,9 @@ module Capybara
|
||||||
def description(node_filters: true, expression_filters: true, **options)
|
def description(node_filters: true, expression_filters: true, **options)
|
||||||
opts = options_with_defaults(options)
|
opts = options_with_defaults(options)
|
||||||
description = +''
|
description = +''
|
||||||
description += undeclared_descriptions.map { |desc| desc.call(opts).to_s }.join
|
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 << 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 << node_filter_descriptions.map { |desc| desc.call(opts).to_s }.join if node_filters
|
||||||
description
|
description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue