From: Rafael Sagula Date: Thu, 28 Jun 2012 23:05:21 +0000 (-0700) Subject: adding StringPiece constructor that takes a piece of another StringPiece X-Git-Tag: v0.22.0~1252 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=e9ee87a62bd54db5fb5c8c8d64151ed2aa75f449;p=folly.git 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 --- 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()) { }