Commit 6696e55c authored by Michael Stella's avatar Michael Stella Committed by Facebook GitHub Bot

Remove unnecessary string copy in JSON serialization

Summary:
`asString()` returns a string by value, which means a copy of the string must be made.

We don't actually need to do this at all:
- We know that the dynamic contains a string, thanks to the switch statement
- The function being called with the result, `escapeString`, only wants a StringPiece anyway.

So this copy is a waste. And uses significant CPU in my application.

Reviewed By: ispeters

Differential Revision: D29812197

fbshipit-source-id: 60df668f7501f78f4282717d6896cd891950b6f5
parent cdb7a478
......@@ -137,7 +137,7 @@ struct Printer {
out_ += "null";
break;
case dynamic::STRING:
escapeString(v.asString(), out_, opts_);
escapeString(v.stringPiece(), out_, opts_);
break;
case dynamic::OBJECT:
printObject(v, context);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment