FastLED 3.9.15
Loading...
Searching...
No Matches

◆ rfind() [4/4]

fl::size fl::string_view::rfind ( string_view sv,
fl::size pos = npos ) const
inline

Definition at line 236 of file string_view.h.

236 {
237 if (sv.empty()) return (pos > mSize) ? mSize : pos;
238 if (sv.mSize > mSize) return npos;
239
240 fl::size max_start = mSize - sv.mSize;
241 fl::size search_start = (pos >= mSize || pos == npos) ? max_start : pos;
242 if (search_start + sv.mSize > mSize) {
243 search_start = max_start;
244 }
245
246 for (fl::size i = search_start + 1; i > 0; --i) {
247 fl::size idx = i - 1;
248 if (idx + sv.mSize > mSize) continue;
249 bool match = true;
250 for (fl::size j = 0; j < sv.mSize; ++j) {
251 if (mData[idx + j] != sv.mData[j]) {
252 match = false;
253 break;
254 }
255 }
256 if (match) return idx;
257 }
258 return npos;
259 }
uint8_t pos
Definition Blur.ino:11
const char * mData
static constexpr fl::size npos
Definition string_view.h:35

References string_view(), FL_NOEXCEPT, mData, mSize, npos, and pos.

+ Here is the call graph for this function: