From e9ee87a62bd54db5fb5c8c8d64151ed2aa75f449 Mon Sep 17 00:00:00 2001 From: Rafael Sagula Date: Thu, 28 Jun 2012 16:05:21 -0700 Subject: [PATCH] adding StringPiece constructor that takes a piece of another StringPiece Summary: adding what seems to be a missing constructor to StringPiece -- I need to be able to take a piece of another StringPiece. (It's possible to do that with all sorts of strings already, except StringPiece...) Test Plan: na -- tested as part of other (dependent) diffs Reviewed By: delong.j@fb.com FB internal diff: D508545 --- folly/Range.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/folly/Range.h b/folly/Range.h index e628cd00..350183a5 100644 --- a/folly/Range.h +++ b/folly/Range.h @@ -160,6 +160,13 @@ public: b_ = str.data() + startFrom; e_ = b_ + size; } + Range(const Range& str, + size_t startFrom, + size_t size) { + CHECK_LE(startFrom + size, str.size()); + b_ = str.b_ + startFrom; + e_ = b_ + size; + } // Works only for Range /* implicit */ Range(const fbstring& str) : b_(str.data()), e_(b_ + str.size()) { } -- 2.34.1