neilconway commented on code in PR #25481:
URL: https://github.com/apache/datafusion/pull/25481#discussion_r4048626467


##########
datafusion/functions-nested/src/position.rs:
##########
@@ -573,9 +568,9 @@ fn array_positions_scalar<O: OffsetSizeTrait>(
 
     // Match positions are relative to visible_values (0-based), so
     // subtract first_offset from each offset when comparing.
-    for i in 0..num_rows {
-        let start = offsets[i].as_usize() - first_offset;
-        let end = offsets[i + 1].as_usize() - first_offset;
+    for (i, window) in offsets.windows(2).enumerate() {
+        let start = window[0].as_usize() - first_offset;
+        let end = window[1].as_usize() - first_offset;

Review Comment:
   I found I had to switch to `windows(2)` to avoid regressing codegen (by 
introducing bounds checks that were otherwise eliminated). Using `windows(2)` 
is arguably more idiomatic, and I checked other locations -- Codex couldn't 
find another place where using the helpers regressed codegen.



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