Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/json/stream/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize
def <<(data)
# Avoid state machine for complete UTF-8.
if @buffer.empty?
data.force_encoding(Encoding::UTF_8)
data = (+data).force_encoding(Encoding::UTF_8)
return data if data.valid_encoding?
end

Expand Down
16 changes: 8 additions & 8 deletions lib/json/stream/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def initialize(&block)

# Track parse stack.
@stack = []
@unicode = ""
@buf = ""
@unicode = +""
@buf = +""
@pos = -1

# Register any observers in the block.
Expand Down Expand Up @@ -178,7 +178,7 @@ def <<(data)
@state = :end_key
notify(:key, @buf)
end
@buf = ""
@buf = +""
when BACKSLASH
@state = :start_escape
when CONTROL
Expand Down Expand Up @@ -270,7 +270,7 @@ def <<(data)
@buf << ch
else
end_value(@buf.to_i)
@buf = ""
@buf = +""
@pos -= 1
redo
end
Expand All @@ -291,7 +291,7 @@ def <<(data)
@buf << ch
else
end_value(@buf.to_f)
@buf = ""
@buf = +""
@pos -= 1
redo
end
Expand All @@ -310,7 +310,7 @@ def <<(data)
else
error('Expected 0-9 digit') unless @buf =~ DIGIT_END
end_value(@buf.to_f)
@buf = ""
@buf = +""
@pos -= 1
redo
end
Expand All @@ -326,7 +326,7 @@ def <<(data)
@buf << ch
else
end_value(@buf.to_i)
@buf = ""
@buf = +""
@pos -= 1
redo
end
Expand Down Expand Up @@ -503,7 +503,7 @@ def keyword(word, value, re, ch)

if @buf.size == word.size
if @buf == word
@buf = ""
@buf = +""
end_value(value)
else
error("Expected #{word} keyword")
Expand Down