Skip to content

Commit

Permalink
Handle IOBuffer signatures on 0.6 and 0.7 (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamed2 authored and TotalVerb committed Feb 25, 2018
1 parent a4ad8ba commit 659c5eb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/specialized.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
function maxsize_buffer(maxsize::Int)
@static if VERSION < v"0.7.0-DEV.3734"
IOBuffer(maxsize)
else
IOBuffer(maxsize=maxsize)
end
end

# Specialized functions for increased performance when JSON is in-memory
function parse_string(ps::MemoryParserState)
# "Dry Run": find length of string so we can allocate the right amount of
Expand All @@ -14,7 +22,7 @@ function parse_string(ps::MemoryParserState)
ps.s = s + len + 2 # byte after closing quote
return unsafe_string(pointer(ps.utf8)+s, len)
else
String(take!(parse_string(ps, IOBuffer(maxsize=len))))
String(take!(parse_string(ps, maxsize_buffer(len))))
end
end

Expand Down

0 comments on commit 659c5eb

Please sign in to comment.