replmd: rework replmd_modify_la_add to merge efficiently
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 29 Dec 2016 00:20:41 +0000 (13:20 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 9 Feb 2017 02:17:15 +0000 (03:17 +0100)
commitbd6b417179938dc89e16672d2290901463355b16
treee17b03ddbd74c25d1e8fce473f44506e14bb69a5
parent06cca52d7824f6615a67938c742236cf6482c811
replmd: rework replmd_modify_la_add to merge efficiently

Because both the list of added links and the list of existing links
are sorted, it is possible to interlace the two and obtain a merged
sorted list.

We avoid a great amount of talloc_realloc()ing by observing that the
merged list can't be longer than the sum of the two lists.

In the (common) case where there are many existing links but few being
added, we avoid parsing most of the existing link DNs and GUIDs if the
sorted_links feature flag is set.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Pair-programmed-with: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c