diff options
Diffstat (limited to 'runtime/mirror/string-inl.h')
-rw-r--r-- | runtime/mirror/string-inl.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/mirror/string-inl.h b/runtime/mirror/string-inl.h index 66e0ef0bdb..0d18b78044 100644 --- a/runtime/mirror/string-inl.h +++ b/runtime/mirror/string-inl.h @@ -67,6 +67,20 @@ int32_t String::FastIndexOf(MemoryType* chars, int32_t ch, int32_t start) { return -1; } +template <typename MemoryType> +int32_t String::LastIndexOf(MemoryType* chars, int32_t ch, int32_t from_index) { + DCHECK_LT(from_index, GetLength()); + const MemoryType* start = chars; + const MemoryType* p = chars + from_index; + while (p >= start) { + if (*p == ch) { + return p - chars; + } + p--; + } + return -1; +} + inline int32_t String::ComputeHashCode() { uint32_t hash = IsCompressed() ? ComputeUtf16Hash(GetValueCompressed(), GetLength()) |