X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Fidl.c;h=a52d3da2752ab26e372eec4a224087704f616503;hb=9f97c1d2efdabc8817538464cd7d08d55f7e51fd;hp=3a4e95efbfb2804256f62517b1d1c1d5ac487139;hpb=1adc0b9b1c39ac588adf22acf46f30e24b802682;p=openldap diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index 3a4e95efbf..a52d3da275 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2000-2011 The OpenLDAP Foundation. + * Copyright 2000-2015 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1089,8 +1089,8 @@ bdb_idl_intersection( * turn it into a range. */ if ( BDB_IDL_IS_RANGE( b ) - && BDB_IDL_RANGE_FIRST( b ) <= BDB_IDL_RANGE_FIRST( a ) - && BDB_IDL_RANGE_LAST( b ) >= BDB_IDL_RANGE_LAST( a ) ) { + && BDB_IDL_RANGE_FIRST( b ) <= BDB_IDL_FIRST( a ) + && BDB_IDL_RANGE_LAST( b ) >= BDB_IDL_LLAST( a ) ) { if (idmax - idmin + 1 == a[0]) { a[0] = NOID; @@ -1357,6 +1357,10 @@ int bdb_idl_append( ID *a, ID *b ) return 0; } + if ( b[0] == 1 ) { + return bdb_idl_append_one( a, BDB_IDL_FIRST( b )); + } + ida = BDB_IDL_LAST( a ); idb = BDB_IDL_LAST( b ); if ( BDB_IDL_IS_RANGE( a ) || BDB_IDL_IS_RANGE(b) || @@ -1367,7 +1371,7 @@ int bdb_idl_append( ID *a, ID *b ) return 0; } - if ( b[0] > 1 && ida > idb ) { + if ( ida > idb ) { swap = idb; a[a[0]] = idb; b[b[0]] = ida; @@ -1382,7 +1386,7 @@ int bdb_idl_append( ID *a, ID *b ) a[0]++; a[a[0]] = tmp; - if ( b[0] > 1 ) { + { int i = b[0] - 1; AC_MEMCPY(a+a[0]+1, b+2, i * sizeof(ID)); a[0] += i; @@ -1450,7 +1454,7 @@ bdb_idl_sort( ID *ids, ID *tmp ) ids[l+1] = ids[j]; ids[j] = a; jstack += 2; - if (ir-i+1 >= j-1) { + if (ir-i+1 >= j-l) { istack[jstack] = ir; istack[jstack-1] = i; ir = j-1; @@ -1468,7 +1472,7 @@ bdb_idl_sort( ID *ids, ID *tmp ) /* 8 bit Radix sort + insertion sort * * based on code from http://www.cubic.org/docs/radix.htm - * with improvements by mbackes@symas.com and hyc@symas.com + * with improvements by ebackes@symas.com and hyc@symas.com * * This code is O(n) but has a relatively high constant factor. For lists * up to ~50 Quicksort is slightly faster; up to ~100 they are even.