Skip to content

Commit

Permalink
Merge branch 'branch-25.04' into cln/dtype/more_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored Mar 4, 2025
2 parents 0537bbd + 93d98af commit d5c29e3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cpp/include/cudf/strings/string_view.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,12 @@ __device__ inline size_type string_view::rfind(char_utf8 chr, size_type pos, siz
__device__ inline string_view string_view::substr(size_type pos, size_type count) const
{
if (pos < 0 || pos >= length()) { return string_view{}; }
auto const itr = begin() + pos;
auto const spos = itr.byte_offset();
auto const epos = count >= 0 ? (itr + count).byte_offset() : size_bytes();
return {data() + spos, epos - spos};
auto const spos = begin() + pos;
auto const epos = count >= 0 ? (spos + count) : const_iterator{*this, _length, size_bytes()};
auto ss = string_view{data() + spos.byte_offset(), epos.byte_offset() - spos.byte_offset()};
// this potentially saves redundant character counting downstream
if (_length != UNKNOWN_STRING_LENGTH) { ss._length = epos.position() - spos.position(); }
return ss;
}

__device__ inline size_type string_view::character_offset(size_type bytepos) const
Expand Down

0 comments on commit d5c29e3

Please sign in to comment.