add IOBuf::maybeCopyBuffer()
authorAdam Simpkins <simpkins@fb.com>
Wed, 14 Nov 2012 04:58:10 +0000 (20:58 -0800)
committerJordan DeLong <jdelong@fb.com>
Sun, 16 Dec 2012 22:45:22 +0000 (14:45 -0800)
commitcb771e84cd1bfd21bfdfb3dd0bae03ecb3ec334f
tree4ae96a910f5e641602e482750f98cc8e26e8a174
parent389fb8a530ecfc37bc441ddb266b1a587d9de06d
add IOBuf::maybeCopyBuffer()

Summary:
Add a version of IOBuf::copyBuffer() which accepts a std::string, as
well as a maybeCopyBuffer() function which returns a null pointer if the
input string is empty.

In proxygen we have a few places where we construct an IOBuf from a
string configuration parameter, and we almost always want a null pointer
rather than an empty IOBuf chain if the string is empty.

Test Plan: Included unit tests for these new functions.

Reviewed By: tudorb@fb.com

FB internal diff: D630547
folly/experimental/io/IOBuf.h
folly/experimental/io/test/IOBufTest.cpp