mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ldb: Make ldb_msg_remove_attr O(n)
Previously it was O(n²). Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
598eaa3474
commit
d5f053711b
@ -1464,11 +1464,18 @@ void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element
|
|||||||
*/
|
*/
|
||||||
void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr)
|
void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr)
|
||||||
{
|
{
|
||||||
struct ldb_message_element *el;
|
unsigned int i;
|
||||||
|
unsigned int num_del = 0;
|
||||||
|
|
||||||
while ((el = ldb_msg_find_element(msg, attr)) != NULL) {
|
for (i = 0; i < msg->num_elements; ++i) {
|
||||||
ldb_msg_remove_element(msg, el);
|
if (ldb_attr_cmp(msg->elements[i].name, attr) == 0) {
|
||||||
|
++num_del;
|
||||||
|
} else if (num_del) {
|
||||||
|
msg->elements[i - num_del] = msg->elements[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg->num_elements -= num_del;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user