added IOBuf::wrapBufferAsValue()
Summary:
Added a version of IOBuf::wrapBuffer() which returns the new IOBuf by value rather than heap-allocating it.
Motivation: we have a lot of places in the crypto code that do something like this:
// take a string or vector parameter
auto buf = folly::IOBuf::wrapBuffer( /* string or vector goes here */);
// do something with buf
// return
In these cases, a stack-allocated IOBuf would save us from an unnecessary heap allocation. But calling `folly::IOBuf(folly::IOBuf::WrapBufferOp::WRAP_BUFFER, ...)` is gross and in practice people just call the much more readable `wrapBuffer()` function. Hypothesis: readability trumps performance, but if we had a readable version that returned a stack-allocated IOBuf, it might see usage.
Reviewed By: yfeldblum
Differential Revision:
D3314037
fbshipit-source-id:
4d4b5ec1d067762a27de1d7d6f7cac406388bfa3