Skip to content

Fix #39, plus a lingering short-string-optimization bug #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2019
Merged
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
5 changes: 1 addition & 4 deletions GraphQLService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,10 +1082,7 @@ std::future<response::Value> Object::resolve(const SelectionSetParams & selectio

response::Value result(response::Type::Map);

if (data.size() > 0)
{
result.emplace_back(strData, std::move(data));
}
result.emplace_back(strData, std::move(data));

if (errors.size() > 0)
{
Expand Down
10 changes: 9 additions & 1 deletion GraphQLTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,15 @@ ast<const char*>::~ast()
ast<std::string> parseString(std::string&& input)
{
ast<std::string> result { std::move(input), nullptr };
memory_input<> in(result.input.c_str(), result.input.size(), "GraphQL");
const size_t length = result.input.size();

if (length < sizeof(result.input))
{
// Overflow the short string optimization so it uses a heap allocation.
result.input.resize(sizeof(result.input));
}

memory_input<> in(result.input.c_str(), length, "GraphQL");

result.root = parse_tree::parse<document, ast_node, ast_selector, nothing, ast_control>(std::move(in));

Expand Down
5 changes: 1 addition & 4 deletions include/graphqlservice/GraphQLService.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,7 @@ struct ModifiedResult

response::Value document(response::Type::Map);

if (data.size() > 0)
{
document.emplace_back(strData, std::move(data));
}
document.emplace_back(strData, std::move(data));

if (errors.size() > 0)
{
Expand Down