andygrove commented on code in PR #19551:
URL: https://github.com/apache/datafusion/pull/19551#discussion_r2658354650
##########
datafusion/functions/src/string/common.rs:
##########
@@ -49,90 +49,69 @@ impl Display for TrimType {
}
}
+/// Perform trim operation on input string with given pattern characters.
+///
+/// Returns (trimmed_str, start_offset) where start_offset is the byte offset
+/// from the beginning of the input string where the trimmed result starts.
+#[inline]
+fn perform_trim<'a>(
+ input: &'a str,
+ pattern: &[char],
+ trim_type: TrimType,
+) -> (&'a str, u32) {
+ match trim_type {
+ TrimType::Left => {
Review Comment:
Results are a little mixed, but mostly better. Also, the code is a little
cleaner with the trait approach, IMO.
| Benchmark | Before | After | Change |
|-------------------------------|---------|---------|--------|
| ltrim string_view short | 50.7 µs | 47.3 µs | −6.6% |
| ltrim large_string short | 44.7 µs | 42.9 µs | −4.1% |
| rtrim string short | 46.0 µs | 45.0 µs | −2.3% |
| rtrim large_string long short | 44.8 µs | 42.8 µs | −4.5% |
| btrim string_view short | 78.1 µs | 78.1 µs | ~0% |
| long trim scenarios | ~280 µs | ~286 µs | +2-3% |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]