From 82b4b1ea013efa2abc16a902e7c0e010e81ecac4 Mon Sep 17 00:00:00 2001 From: Fengyang Wang Date: Thu, 20 Apr 2017 17:04:03 -0400 Subject: [PATCH] Use StringVector instead of Vector{UInt8} This avoids extra allocation and copying for the in-memory string parsing. --- REQUIRE | 2 +- src/specialized.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/REQUIRE b/REQUIRE index c7eded8..7274a2c 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ julia 0.4 -Compat 0.17.0 +Compat 0.24.0 diff --git a/src/specialized.jl b/src/specialized.jl index 6ee9967..4f759d1 100644 --- a/src/specialized.jl +++ b/src/specialized.jl @@ -1,4 +1,5 @@ # Specialized functions for increased performance when JSON is in-memory +using Compat: StringVector function parse_string(ps::MemoryParserState) # "Dry Run": find length of string so we can allocate the right amount of @@ -6,7 +7,7 @@ function parse_string(ps::MemoryParserState) fastpath, len = predict_string(ps) # Now read the string itself - b = Vector{UInt8}(len) + b = StringVector(len) # Fast path occurs when the string has no escaped characters. This is quite # often the case in real-world data, especially when keys are short strings.