diff --git a/awkward-cpp/src/cpu-kernels/awkward_Index_nones_as_index.cpp b/awkward-cpp/src/cpu-kernels/awkward_Index_nones_as_index.cpp index bef9e2b83d..ad2febc39e 100644 --- a/awkward-cpp/src/cpu-kernels/awkward_Index_nones_as_index.cpp +++ b/awkward-cpp/src/cpu-kernels/awkward_Index_nones_as_index.cpp @@ -9,14 +9,14 @@ ERROR awkward_Index_nones_as_index( T* toindex, int64_t length) { int64_t n_non_null = 0; - // Assuming that `toindex` comprises of contiguous integers, and is zero-based + // Assuming that `toindex` comprises of unique, contiguous integers (or -1), and is zero-based // Compute the number of non-null values to determine our starting index for (int64_t i = 0; i < length; i++) { if (toindex[i] != -1) { n_non_null++; } } - // + // Now set the null-value indices to by monotonically increasing and unique from the final index for (int64_t i = 0; i < length; i++) { toindex[i] == -1 ? toindex[i] = n_non_null++ : toindex[i]; }