rustyconover commented on PR #558:
URL: https://github.com/apache/datasketches-cpp/pull/558#issuecomment-6525634711

   @proost thanks for the review, agreed on both points. I've pushed 1fcf432f, 
which moves all handling of an unallocated `items_` into the helpers that own 
the item storage, so callers no longer guard anything:
   
   - **`allocate_items()`** is the only place `items_` gets allocated (update 
and merge).
   - **`copy_items()`** is the only place items are copied. The copy and 
converting constructors both use it, which replaces their duplicated null 
checks.
   - **`item_ptr(index)`** is the only place an item index becomes a pointer 
for readers. Without item storage it returns `nullptr`, so every level range is 
empty. `sort_level_zero()`, `check_sorting()` and `get_sorted_view()` go 
through it and no longer need guards of their own.
   
   That also lets me drop the `is_empty()` early return I had added to 
`get_sorted_view()`, so it's back to its original form. Serialization and the 
quantile and rank queries already check `is_empty()` before touching items. The 
iterator already treats a null `items_` as `begin() == end()`.
   
   To confirm the guard is load-bearing: if I put the raw `items_ + levels_[0]` 
back in `sort_level_zero()`, the UBSan build fails the new empty-sketch tests 
with `applying non-zero offset 800 to null pointer`. With `item_ptr()`, 
`kll_test` passes in Release, UBSan (`undefined,float-cast-overflow`) and ASan 
builds.
   
   The CI workflows on this PR are still waiting for maintainer approval, so 
they haven't run yet.
   


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