From de0fe30ec67f09ae0870cb8a390a330c1dbb0de5 Mon Sep 17 00:00:00 2001 From: Philip Pronin Date: Thu, 10 Oct 2013 12:12:36 -0700 Subject: [PATCH] make IOBuf::coalesce return ByteRange Test Plan: fbconfig -r folly/io && fbmake opt -j32 && fbmake runtests_opt @override-unit-failures Reviewed By: soren@fb.com FB internal diff: D1005735 --- folly/io/IOBuf.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/folly/io/IOBuf.h b/folly/io/IOBuf.h index 7d96e02f..a071ba33 100644 --- a/folly/io/IOBuf.h +++ b/folly/io/IOBuf.h @@ -895,12 +895,14 @@ class IOBuf { * Throws std::bad_alloc on error. On error the IOBuf chain will be * unmodified. Throws std::overflow_error if the length of the entire chain * larger than can be described by a uint32_t capacity. + * + * Returns ByteRange that points to the data IOBuf stores. */ - void coalesce() { - if (!isChained()) { - return; + ByteRange coalesce() { + if (isChained()) { + coalesceSlow(); } - coalesceSlow(); + return ByteRange(data_, length_); } /** -- 2.34.1