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

Why do this comparison "match_elem == cmp" ? #1493

Closed
DavidLiuXh opened this issue Oct 30, 2017 · 3 comments
Closed

Why do this comparison "match_elem == cmp" ? #1493

DavidLiuXh opened this issue Oct 30, 2017 · 3 comments
Labels

Comments

@DavidLiuXh
Copy link

https://github.com/edenhill/librdkafka/blob/0c2ed0a2289f926780d228698b30a71968292503/src/rdlist.c#L144

Why do this comparison "match_elem == cmp" ?

@edenhill
Copy link
Contributor

It is an optimization, if the object pointers are the same there is no need to call the comparator since it is the same object.

@rolandyoung
Copy link

But should the expression not be match_elem == elem ? As it is, the code appears to be comparing the pointer to one of the objects with the pointer to the comparator function.

@edenhill
Copy link
Contributor

Ha, yes, you are both right, sorry! Reading too fast.

@edenhill edenhill reopened this Oct 31, 2017
@edenhill edenhill added bug and removed question labels Oct 31, 2017
@edenhill edenhill closed this as completed Nov 9, 2017
@edenhill edenhill reopened this Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants