Skip to content
Closed
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 src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Reader::Reader(const Features& features)

bool
Reader::parse(const std::string& document, Value& root, bool collectComments) {
JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity());
JSONCPP_STRING documentCopy(document.data(), document.data() + document.length());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSONCPP_STRING is going to be some kind of std::basic_string. The allocator changes with different build configurations. So it has the full std::string constructor API.

JSONCPP_STRING documentCopy(document.begin(), document.end());

But really we don't need documentCopy at all. The swap doesn't seem to be doing anything we can't do better with an assignment.

document_.assign(document.begin(), document.end());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @BillyDonahue.

std::swap(documentCopy, document_);
const char* begin = document_.c_str();
const char* end = begin + document_.length();
Expand Down