s4-dsdb: use DLIST_ADD() not DLIST_ADD_END()
authorAndrew Tridgell <tridge@samba.org>
Tue, 15 Sep 2009 17:01:26 +0000 (10:01 -0700)
committerAndrew Tridgell <tridge@samba.org>
Tue, 15 Sep 2009 17:01:26 +0000 (10:01 -0700)
Using DLIST_ADD_END() to construct a long list is very inefficient (it
is O(n^2). These lists are not ordered, so using DLIST_ADD() is much
better.

source4/dsdb/schema/schema_init.c
source4/dsdb/schema/schema_set.c

index 3b701ad31c5246c6af6d842cd61bcdbedab1a195..9f7d96715867f3eacd840412f5d019636b2339bc 100644 (file)
@@ -967,7 +967,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
                        return LDB_ERR_CONSTRAINT_VIOLATION;
                }
 
-               DLIST_ADD_END(schema->attributes, sa, struct dsdb_attribute *);
+               DLIST_ADD(schema->attributes, sa);
        }
 
        for (i=0; i < objectclass_res->count; i++) {
@@ -988,7 +988,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
                        return LDB_ERR_CONSTRAINT_VIOLATION;
                }
 
-               DLIST_ADD_END(schema->classes, sc, struct dsdb_class *);
+               DLIST_ADD(schema->classes, sc);
        }
 
        schema->fsmo.master_dn = ldb_msg_find_attr_as_dn(ldb, schema, schema_res->msgs[0], "fSMORoleOwner");
index 6745bde127fd774a10f811b37caeb8912e9e5019..6f09f635960e1cfddd709d285bdcf44304ec7fcb 100644 (file)
@@ -555,7 +555,7 @@ WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb, const char *pf, const
                                goto failed;
                        }
 
-                       DLIST_ADD_END(schema->attributes, sa, struct dsdb_attribute *);
+                       DLIST_ADD(schema->attributes, sa);
                } else if (is_sc) {
                        struct dsdb_class *sc;
 
@@ -569,7 +569,7 @@ WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb, const char *pf, const
                                goto failed;
                        }
 
-                       DLIST_ADD_END(schema->classes, sc, struct dsdb_class *);
+                       DLIST_ADD(schema->classes, sc);
                }
        }