Skip to content

Commit

Permalink
Avoid unecessary unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Sep 23, 2024
1 parent 307850a commit 064450f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions datafusion/functions/src/string/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ fn trim_and_append_str<'a>(
if let (Some(src_str), Some(characters)) = (src_str_opt, trim_characters_opt) {
let trim_str = trim_func(src_str, characters);

// Safety:
// `trim_str` is computed from `str::trim_xxx_matches`,
// and its addr is ensured to be >= `origin_str`'s
let start = unsafe { trim_str.as_ptr().offset_from(src_str.as_ptr()) as u32 };
let start = (src_str.as_bytes().len() - trim_str.as_bytes().len()) as u32;

make_and_append_view(views_buf, null_builder, raw, trim_str, start);
} else {
Expand Down

0 comments on commit 064450f

Please sign in to comment.