File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
tools/SourceKit/tools/sourcekitd/lib/API Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -2423,9 +2423,14 @@ void serializeSyntaxTreeAsJson(
2423
2423
const swift::syntax::SourceFileSyntax &SyntaxTree,
2424
2424
std::unordered_set<unsigned > ReusedNodeIds,
2425
2425
ResponseBuilder::Dictionary &Dict) {
2426
+ // 4096 is a heuristic buffer size that appears to usually be able to fit an
2427
+ // incremental syntax tree
2428
+ size_t ReserveBufferSize = 4096 ;
2426
2429
std::string SyntaxTreeString;
2430
+ SyntaxTreeString.reserve (ReserveBufferSize);
2427
2431
{
2428
2432
llvm::raw_string_ostream SyntaxTreeStream (SyntaxTreeString);
2433
+ SyntaxTreeStream.SetBufferSize (ReserveBufferSize);
2429
2434
swift::json::Output::UserInfoMap JsonUserInfo;
2430
2435
JsonUserInfo[swift::json::OmitNodesUserInfoKey] = &ReusedNodeIds;
2431
2436
swift::json::Output SyntaxTreeOutput (SyntaxTreeStream, JsonUserInfo,
You can’t perform that action at this time.
0 commit comments