Skip to content

Commit

Permalink
use String.new instead of empty string constants
Browse files Browse the repository at this point in the history
to support use of frozen string literals.
  • Loading branch information
flavorjones committed Nov 13, 2017
1 parent b060679 commit 46f0146
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/crass/parser.rb
Expand Up @@ -73,7 +73,7 @@ def self.parse_stylesheet(input, options = {})
#
def self.stringify(nodes, options = {})
nodes = [nodes] unless nodes.is_a?(Array)
string = ''
string = String.new

nodes.each do |node|
next if node.nil?
Expand Down Expand Up @@ -614,7 +614,7 @@ def parse_rule(input = @tokens)
# Returns the unescaped value of a selector name or property declaration.
def parse_value(nodes)
nodes = [nodes] unless nodes.is_a?(Array)
string = ''
string = String.new

nodes.each do |node|
case node[:node]
Expand Down
12 changes: 6 additions & 6 deletions lib/crass/tokenizer.rb
Expand Up @@ -273,7 +273,7 @@ def consume
#
# 4.3.15. http://dev.w3.org/csswg/css-syntax/#consume-the-remnants-of-a-bad-url
def consume_bad_url
text = ''
text = String.new

until @s.eos?
if valid_escape?
Expand Down Expand Up @@ -373,7 +373,7 @@ def consume_ident
#
# 4.3.12. http://dev.w3.org/csswg/css-syntax/#consume-a-name
def consume_name
result = ''
result = String.new

until @s.eos?
if match = @s.scan(RE_NAME)
Expand Down Expand Up @@ -405,7 +405,7 @@ def consume_name
#
# 4.3.13. http://dev.w3.org/csswg/css-syntax/#consume-a-number
def consume_number
repr = ''
repr = String.new
type = :integer

repr << @s.consume if @s.peek =~ RE_NUMBER_SIGN
Expand Down Expand Up @@ -459,7 +459,7 @@ def consume_numeric
# 4.3.5. http://dev.w3.org/csswg/css-syntax/#consume-a-string-token
def consume_string(ending = nil)
ending = @s.current if ending.nil?
value = ''
value = String.new

until @s.eos?
case char = @s.consume
Expand Down Expand Up @@ -499,7 +499,7 @@ def consume_string(ending = nil)
#
# 4.3.7. http://dev.w3.org/csswg/css-syntax/#consume-a-unicode-range-token
def consume_unicode_range
value = @s.scan(RE_HEX) || ''
value = @s.scan(RE_HEX) || String.new

while value.length < 6
break unless @s.peek == '?'
Expand Down Expand Up @@ -531,7 +531,7 @@ def consume_unicode_range
#
# 4.3.6. http://dev.w3.org/csswg/css-syntax/#consume-a-url-token
def consume_url
value = ''
value = String.new

@s.scan(RE_WHITESPACE)

Expand Down

0 comments on commit 46f0146

Please sign in to comment.