This code block does linear search, which can take O(n) time can we replace with pattern search considering domain sid strings would be similar, just few bytes would differ?
This may make few microsec difference but summation of microseconds can be significant in bigger enviornment.
#define WBC_MAXSUBAUTHS 15
#define FSTRING_LEN 256
typedef char fstring[FSTRING_LEN];
int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2)
for (i = sid1->num_auths-1; i >= 0; --i)
if (sid1->sub_auths[i] != sid2->sub_auths[i])
return sid1->sub_auths[i] - sid2->sub_auths[i];
Amit, thanks for looking into improving Samba.
To me this doesn't look to be a bug, but instead a possible performance improvement which you may want to discuss on the samba-technical mailing list.
I don't think Samba bugzilla is the right place to discuss this.
If you agree, please close the bugs and start a discussion on the mailing list. Thanks!
Please also take care that as a _compare function, the ordering of the result may be depended on by callers, so any change here would need an extensive testsuite.