Skip to content

Commit

Permalink
refactor(rust): don't decode into utf8 (#5910)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Dec 26, 2022
1 parent 8060006 commit ba5c827
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions polars/polars-core/src/chunked_array/strings/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ use crate::prelude::*;
impl Utf8Chunked {
#[cfg(not(feature = "binary_encoding"))]
pub fn hex_decode(&self) -> PolarsResult<Utf8Chunked> {
self.try_apply(|s| {
let bytes =
hex::decode(s).map_err(|e| PolarsError::ComputeError(e.to_string().into()))?;
let s = String::from_utf8(bytes)
.map_err(|e| PolarsError::ComputeError(e.to_string().into()))?;
Ok(s.into())
})
panic!("activate 'dtype-binary' feature")
}

#[cfg(feature = "binary_encoding")]
Expand All @@ -28,13 +22,7 @@ impl Utf8Chunked {

#[cfg(not(feature = "binary_encoding"))]
pub fn base64_decode(&self) -> PolarsResult<Utf8Chunked> {
self.try_apply(|s| {
let bytes =
base64::decode(s).map_err(|e| PolarsError::ComputeError(e.to_string().into()))?;
let s = String::from_utf8(bytes)
.map_err(|e| PolarsError::ComputeError(e.to_string().into()))?;
Ok(s.into())
})
panic!("activate 'dtype-binary' feature")
}

#[cfg(feature = "binary_encoding")]
Expand Down

0 comments on commit ba5c827

Please sign in to comment.