Skip to content

Commit 59295ee

Browse files
committed
cleanup
1 parent d17eb0c commit 59295ee

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

src/lib.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,6 @@ pub fn first_true_2d<'py>(
487487
axis: isize,
488488
) -> PyResult<Bound<'py, PyArray1<isize>>> {
489489

490-
// let prepped = prepare_array_for_axis(py, array, axis)?;
491-
// let view = unsafe { prepped.as_array() };
492-
// // NOTE: these are rows in the view, not always the same as rows
493-
// let rows = view.nrows();
494-
495490
let prepared = prepare_array_for_axis(py, array, axis)?;
496491
let data = prepared.data;
497492
let rows = prepared.nrows;
@@ -502,18 +497,10 @@ pub fn first_true_2d<'py>(
502497
py.allow_threads(|| {
503498
const LANES: usize = 32;
504499
let ones = u8x32::splat(1);
505-
506500
let base_ptr = data.as_ptr();
507501

508502
for row in 0..rows {
509-
510503
let ptr = unsafe { base_ptr.add(row * row_len) };
511-
512-
// let mut found = -1;
513-
// let row_slice = &view.row(row);
514-
// let ptr = row_slice.as_ptr() as *const u8;
515-
// let len = row_slice.len();
516-
517504
if forward {
518505
// Forward search
519506
let mut i = 0;
@@ -528,7 +515,6 @@ pub fn first_true_2d<'py>(
528515
}
529516
while i < row_len {
530517
if *ptr.add(i) != 0 {
531-
// found = i as isize;
532518
result[row] = i as isize;
533519
break;
534520
}
@@ -542,13 +528,13 @@ pub fn first_true_2d<'py>(
542528
// Process LANES bytes at a time with SIMD (backwards)
543529
while i >= LANES {
544530
i -= LANES;
531+
545532
let chunk = &*(ptr.add(i) as *const [u8; LANES]);
546533
let vec = u8x32::from(*chunk);
547534
if vec.cmp_eq(ones).any() {
548535
// Found a true in this chunk, search backwards within it
549536
for j in (i..i + LANES).rev() {
550537
if *ptr.add(j) != 0 {
551-
// found = j as isize;
552538
result[row] = j as isize;
553539
break;
554540
}
@@ -560,7 +546,6 @@ pub fn first_true_2d<'py>(
560546
if i > 0 && i < LANES {
561547
for j in (0..i).rev() {
562548
if *ptr.add(j) != 0 {
563-
// found = j as isize;
564549
result[row] = j as isize;
565550
break;
566551
}
@@ -570,7 +555,6 @@ pub fn first_true_2d<'py>(
570555
}
571556
}
572557
});
573-
574558
Ok(PyArray1::from_vec(py, result).to_owned())
575559
}
576560

0 commit comments

Comments
 (0)