Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shadow warnings on hash_table8.hpp #42

Closed
zufuliu opened this issue Dec 2, 2024 · 2 comments
Closed

Shadow warnings on hash_table8.hpp #42

zufuliu opened this issue Dec 2, 2024 · 2 comments

Comments

@zufuliu
Copy link

zufuliu commented Dec 2, 2024

See ninja-build/ninja#2531, there are shadow warnings when using MSVC /W4 or GCC/Clang -Wshadow=local:

first one inside find_filled_bucket():

emhash/hash_table8.hpp

Lines 1325 to 1337 in afd962a

const auto slot = _index[bucket].slot & _mask;
//prefetch_heap_block((char*)&_pairs[slot]);
if (EMH_EQHASH(bucket, key_hash)) {
if (EMH_LIKELY(_eq(key, _pairs[slot].first)))
return bucket;
}
if (next_bucket == bucket)
return INACTIVE;
while (true) {
if (EMH_EQHASH(next_bucket, key_hash)) {
const auto slot = _index[next_bucket].slot & _mask;
if (EMH_LIKELY(_eq(key, _pairs[slot].first)))

second one inside find_filled_slot():

emhash/hash_table8.hpp

Lines 1360 to 1371 in afd962a

const auto slot = _index[bucket].slot & _mask;
//prefetch_heap_block((char*)&_pairs[slot]);
if (EMH_EQHASH(bucket, key_hash)) {
if (EMH_LIKELY(_eq(key, _pairs[slot].first)))
return slot;
}
if (next_bucket == bucket)
return _num_filled;
while (true) {
if (EMH_EQHASH(next_bucket, key_hash)) {
const auto slot = _index[next_bucket].slot & _mask;

maybe the inner slot could be renamed to eslot (as in find_or_allocate()) or something else:

emhash/hash_table8.hpp

Lines 1494 to 1509 in afd962a

const auto slot = _index[bucket].slot & _mask;
if (EMH_EQHASH(bucket, key_hash))
if (EMH_LIKELY(_eq(key, _pairs[slot].first)))
return bucket;
//check current bucket_key is in main bucket or not
const auto kmain = hash_bucket(_pairs[slot].first);
if (kmain != bucket)
return kickout_bucket(kmain, bucket);
else if (next_bucket == bucket)
return _index[next_bucket].next = find_empty_bucket(next_bucket, 1);
uint32_t csize = 1;
//find next linked bucket and check key
while (true) {
const auto eslot = _index[next_bucket].slot & _mask;

@ktprime
Copy link
Owner

ktprime commented Dec 3, 2024

thanks, I have fixed the issues in latest version.

@zufuliu
Copy link
Author

zufuliu commented Dec 3, 2024

Thanks.

@zufuliu zufuliu closed this as completed Dec 3, 2024
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

No branches or pull requests

2 participants