typedef int type;
};
+// Prevent it from being inlined to reduce instruction bloat.
+FOLLY_NOINLINE inline void throwOutOfRange() {
+ throw std::out_of_range("index out of range");
+}
+
} // namespace detail
/**
template <class T = Iter, typename detail::IsCharPointer<T>::const_type = 0>
Range(const std::string& str, std::string::size_type startFrom) {
if (UNLIKELY(startFrom > str.size())) {
- throw std::out_of_range("index out of range");
+ detail::throwOutOfRange();
}
b_ = str.data() + startFrom;
e_ = str.data() + str.size();
std::string::size_type startFrom,
std::string::size_type size) {
if (UNLIKELY(startFrom > str.size())) {
- throw std::out_of_range("index out of range");
+ detail::throwOutOfRange();
}
b_ = str.data() + startFrom;
if (str.size() - startFrom < size) {
template <class T = Iter, typename detail::IsCharPointer<T>::const_type = 0>
Range(const fbstring& str, fbstring::size_type startFrom) {
if (UNLIKELY(startFrom > str.size())) {
- throw std::out_of_range("index out of range");
+ detail::throwOutOfRange();
}
b_ = str.data() + startFrom;
e_ = str.data() + str.size();
Range(const fbstring& str, fbstring::size_type startFrom,
fbstring::size_type size) {
if (UNLIKELY(startFrom > str.size())) {
- throw std::out_of_range("index out of range");
+ detail::throwOutOfRange();
}
b_ = str.data() + startFrom;
if (str.size() - startFrom < size) {
}
value_type& at(size_t i) {
- if (i >= size()) throw std::out_of_range("index out of range");
+ if (i >= size()) detail::throwOutOfRange();
return b_[i];
}
const value_type& at(size_t i) const {
- if (i >= size()) throw std::out_of_range("index out of range");
+ if (i >= size()) detail::throwOutOfRange();
return b_[i];
}
void advance(size_type n) {
if (UNLIKELY(n > size())) {
- throw std::out_of_range("index out of range");
+ detail::throwOutOfRange();
}
b_ += n;
}
void subtract(size_type n) {
if (UNLIKELY(n > size())) {
- throw std::out_of_range("index out of range");
+ detail::throwOutOfRange();
}
e_ -= n;
}
Range subpiece(size_type first, size_type length = npos) const {
if (UNLIKELY(first > size())) {
- throw std::out_of_range("index out of range");
+ detail::throwOutOfRange();
}
return Range(b_ + first, std::min(length, size() - first));
} else if (e == e_) {
e_ = b;
} else {
- throw std::out_of_range("index out of range");
+ detail::throwOutOfRange();
}
}