util/chd: use data() instead of &container[0] - #15888
Closed
simzy39 wants to merge 9 commits into
Closed
Conversation
Replaces &container[0] with container.data() where a pointer to the start of a standard library container is required. Uses that refer to an offset within a container are left unchanged. This makes the intent clearer and avoids indexing the first element just to obtain the underlying data pointer. No functional change intended. AI assistance: GPT-5.6 Sol (OpenAI) was used to help identify applicable instances and review the changes. Grok 4.5 was used as an additional code review.
util/chd: replace qsort with std::sort for metadata hashes Add operator< to metadata_hash and use std::sort instead of the C qsort + function pointer. Remove the now-unused metadata_hash_compare helper.
Removed unnecessary inclusion of cstdlib header, no longer needed after removing qsort
Move the metadata_hash comparison from operator< to a local std::sort lambda, keeping the comparison logic at the point where it is used.
Use vector::data() when passing the metadata input buffer, matching the same container access cleanup in chd.cpp.
Use the C++20 std::bit_width function instead of the custom bits_for_value implementation.
Remove the now-unused bits_for_value declaration from chd.h after replacing the implementation with std::bit_width.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces &container[0] with container.data() where a pointer to the start of a standard library container is required. Uses that refer to an offset within a container are left unchanged.
This makes the intent clearer and avoids indexing the first element just to obtain the underlying data pointer. No functional change intended.
AI assistance: GPT-5.6 Sol (OpenAI) was used to help identify applicable instances and review the changes. Grok 4.5 was used as an additional code review.