[PATCH] D141446: [llvm-profdata] Add option to cap profile output size
William Junda Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 6 17:07:15 PST 2023
huangjd added inline comments.
================
Comment at: llvm/lib/ProfileData/SampleProfWriter.cpp:111
+ StringBuffer.clear();
+ OutputStream.reset(new raw_svector_ostream(StringBuffer));
+ if (std::error_code EC = write(ProfileMap))
----------------
snehasish wrote:
> Is this leaking the raw_svector_ostream objects?
>
> Can we rewrite this as the following?
>
> ```
> raw_svector_ostream OS(StringBuffer);
> OutputStream.reset(&OS);
> ```
>
> Also might be worth it to use a separate OutputStream object within the loop scope so that we don't have to worry about the swap before and after and the lifetimes of the raw_vector_ostream objects.
unique_ptr.reset(new obj) is the correct usage.
https://en.cppreference.com/w/cpp/memory/unique_ptr/reset
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141446/new/
https://reviews.llvm.org/D141446
More information about the llvm-commits
mailing list