2010YOUY01 commented on code in PR #20295:
URL: https://github.com/apache/datafusion/pull/20295#discussion_r2796563868


##########
datafusion/functions/src/unicode/strpos.rs:
##########
@@ -179,6 +180,31 @@ fn strpos(args: &[ArrayRef]) -> Result<ArrayRef> {
     }
 }
 
+/// Find `needle` in `haystack` using `memchr` to quickly skip to positions
+/// where the first byte matches, then verify the remaining bytes. Using
+/// string::find is slower because it has significant per-call overhead that
+/// `memchr` does not, and strpos is often invoked many times on short inputs.
+/// Returns a 1-based position, or 0 if not found.
+/// Both inputs must be ASCII-only.
+fn find_ascii_substring(haystack: &[u8], needle: &[u8]) -> usize {

Review Comment:
   Is it possible to use `memchr::memmem::find()` directly? Based on the 
`Complexity` section, it seems has implemented the same algorithm.
   https://docs.rs/memchr/latest/memchr/memmem/fn.find.html



-- 
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]

Reply via email to