[PATCH] D93531: [clangd] Reuse buffer for JSONTransport::readRawMessage

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 18 07:08:35 PST 2020


sammccall added a comment.

This adds a bit of complexity, making the code here a fair amount harder to follow and verify the correctness of.

- Do we have evidence that these allocations are causing a problem? (e.g. do we observe a significant decrease in RSS after the patch)? Naively I would expect these allocations to be basically unimportant compared to those of the JSON objects themselves.(And I don't particularly expect either of them to be significant - the comment on the other review was really just "0 probably isn't the right arg to  malloc_trim if there's any allocation going on").
- there seem to be simpler ways to structure this avoiding allocations. JSONLineBuffer is effectively statically bounded, and can be `SmallString<32>` or so. The content buffer could simply be passed in if I'm reading right: `bool readRawMessage(std::string&)`? OutputBuffer probably does need to be a member variable though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93531/new/

https://reviews.llvm.org/D93531



More information about the cfe-commits mailing list