make IOBuf::coalesce return ByteRange
authorPhilip Pronin <philipp@fb.com>
Thu, 10 Oct 2013 19:12:36 +0000 (12:12 -0700)
committerSara Golemon <sgolemon@fb.com>
Thu, 24 Oct 2013 21:53:41 +0000 (14:53 -0700)
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

index 7d96e02f542f906f3d5e9300838cb59ca4ceea94..a071ba3390f81c3542b1bb9cee2a3a41bfa545a0 100644 (file)
@@ -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_);
   }
 
   /**