lib: Some smaller code fixes for typesafe hash _member function - #22233
Merged
donaldsharp merged 2 commits intoJun 8, 2026
Merged
Conversation
Greptile SummaryThis PR fixes two small issues in the typesafe hash
Confidence Score: 5/5Both changes are safe to merge: the return false fix and the loop restructure are semantically correct and consistent with the existing patterns in _del and _const_find. The dead while loop in the original code was harmless in practice since the for loop immediately reset hitem, and the new two-while pattern behaves identically. The return false fix is unconditionally correct. No edge cases are introduced. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[_member called] --> B{tabshift == 0?}
B -- yes --> C[return false]
B -- no --> D[compute hval and hbits]
D --> E[hitem = entries at hbits]
E --> F{hitem exists AND hashval less than hval?}
F -- yes --> G[advance hitem]
G --> F
F -- no --> H{hitem exists AND hashval equals hval?}
H -- yes --> I{hitem is item field?}
I -- yes --> J[return true]
I -- no --> K[advance hitem]
K --> H
H -- no --> L[return false]
Reviews (1): Last reviewed commit: "lib: Remove unnecessary comparison loop ..." | Re-trigger Greptile |
Typesafe hash _member has return type bool, but the initial check did return NULL which is somehow valid due to C semantics, but misleading Signed-off-by: Robin Christ <r.christ@partimus.com>
The typesafe hash _member function basically walked through the table twice because the result of the first while loop was discarded in the for loop init. Remove the for loop and replace with a while loop, this makes the function similar to _del Signed-off-by: Robin Christ <r.christ@partimus.com>
robinchrist
force-pushed
the
lib-fix-hash-member-return-value
branch
from
June 6, 2026 12:04
dcc8ef0 to
b3696d2
Compare
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.
While looking through the code for the typesafe hash, I noticed some smaller inconsistencies in the typeseafe hash
_memberfunction:if (!h->hh.tabshift)didreturn NULL. The functions return type isbool. While this works, it's misleadingwhileloop was simply discarded in theforinit and loop did not do anything useful. Replaced theforwith anotherwhile, so this aligns e.g. with_del