[PATCH] D111252: [llvm] [Support] [Debuginfo] Add http and debuginfod client libraries and llvm-debuginfod-find tool
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 14 11:27:20 PDT 2021
phosek added inline comments.
================
Comment at: llvm/lib/Support/HTTPClient.cpp:31
+ size_t BufferSize = Buffer->size();
+ Buffer->resize(BufferSize + ChunkSize);
+ memcpy(&(Buffer[BufferSize]), Contents, ChunkSize);
----------------
One potential downside of this approach is you may have to resize the buffer multiple times as the data comes in which would be inefficient.
I was reading about alternatives, one possibility would be check a priori what's the size of the resource you're fetching is by performing a HEAD request (via `CURLOPT_NOBODY` and `CURLOPT_HEADER` set to 1) asking for the HTTP headers to be written via `CURLOPT_WRITEHEADER` and `CURLOPT_WRITEFUNCTION` and parsing the `Content-Length` value. Then you can allocate an appropriately sized buffer and fetch the actual content. You might even use `WritableMemoryBuffer::getNewUninitMemBuffer` instead of `std::vector` since you don't need to resize.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111252/new/
https://reviews.llvm.org/D111252
More information about the llvm-commits
mailing list