Skip to content

util/chd: use data() instead of &container[0] - #15888

Closed
simzy39 wants to merge 9 commits into
mamedev:masterfrom
simzy39:patch-3
Closed

util/chd: use data() instead of &container[0]#15888
simzy39 wants to merge 9 commits into
mamedev:masterfrom
simzy39:patch-3

Conversation

@simzy39

@simzy39 simzy39 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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.

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.
@simzy39 simzy39 closed this Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant