ldb patch

Andrew Bartlett abartlet at samba.org
Mon Apr 30 04:34:02 MDT 2012


On Mon, 2012-04-30 at 00:26 -0700, Matthieu Patou wrote:
> Hello Simo,
> 
> Any objection with this patch ?
> 
> The idea is to use this function in samldb modules when comparing 
> attributes name instead of using just strcmp. Comparing first the string 
> length should speed up the comparison in most cases.
> 

Matthieu,

I have two concerns, from different directions:
 - first, ldb_val_cmp, if implemented, should not use strcmp or
strncmp().  struct ldb_val is a data/length tuple, and may contain
embedded nul (\0) bytes.  memcmp is the only suitable comparator.

 - I also think it is premature optimisation.  A strcmp, and a memcmp
will return non-zero at the first different byte.  Additionally, I have
looked at what is 'hot' in our ldb code, and it is schema lookups,
particularly from the resolve_oid module, not samldb.  The transaction
costs (fsync()) would overwealm anything else in samldb. 

Finally, for use in samldb, which is Samba code, why not just use
data_blob_cmp()?

Andrew Bartlett

-- 
Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org



More information about the samba-technical mailing list