dsdb-schema: remove looping on all schema classes for system_possible_inferrior
authorMatthieu Patou <mat@matws.net>
Tue, 22 Jan 2013 06:27:10 +0000 (22:27 -0800)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 20 May 2013 11:52:38 +0000 (21:52 +1000)
The logic to populate possible inferriors and system possible inferriors
is the same so instead of looping twice we do both attributes (depending
on the type of the class) in the same loop

Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/schema/schema_inferiors.c

index 2f7d46131b4b78b488d128e2c53818889265c284..4d095216742885cf9ba8bc9865125fe0aaf06f7f 100644 (file)
@@ -201,45 +201,31 @@ static void schema_fill_possible_inferiors(const struct dsdb_schema *schema,
                                           struct dsdb_class *schema_class)
 {
        struct dsdb_class *c2;
+       const char** poss_inf = schema_class->possibleInferiors;
+       const char** sys_poss_inf = schema_class->systemPossibleInferiors;
 
-       schema_class->possibleInferiors = NULL;
-
-       for (c2=schema->classes; c2; c2=c2->next) {
+       for (c2 = schema->classes; c2; c2 = c2->next) {
                const char **superiors = schema_posssuperiors(schema, c2);
-               if (c2->systemOnly == false 
-                   && c2->objectClassCategory != 2 
-                   && c2->objectClassCategory != 3
-                   && str_list_check(superiors, schema_class->lDAPDisplayName)) {
-                       if (schema_class->possibleInferiors == NULL) {
-                               schema_class->possibleInferiors = const_str_list(str_list_make_empty(schema_class));
+               if (c2->objectClassCategory != 2 &&
+                   c2->objectClassCategory != 3 &&
+                   str_list_check(superiors, schema_class->lDAPDisplayName))
+               {
+                       if (c2->systemOnly == false) {
+                               if (poss_inf == NULL) {
+                                       poss_inf = const_str_list(str_list_make_empty(schema_class));
+                               }
+                               poss_inf = str_list_add_const(poss_inf,
+                                                             c2->lDAPDisplayName);
                        }
-                       schema_class->possibleInferiors = str_list_add_const(schema_class->possibleInferiors,
-                                                       c2->lDAPDisplayName);
-               }
-       }
-       schema_class->possibleInferiors = str_list_unique(schema_class->possibleInferiors);
-}
-
-static void schema_fill_system_possible_inferiors(const struct dsdb_schema *schema,
-                                                 struct dsdb_class *schema_class)
-{
-       struct dsdb_class *c2;
-
-       schema_class->systemPossibleInferiors = NULL;
-
-       for (c2=schema->classes; c2; c2=c2->next) {
-               const char **superiors = schema_posssuperiors(schema, c2);
-               if (c2->objectClassCategory != 2
-                   && c2->objectClassCategory != 3
-                   && str_list_check(superiors, schema_class->lDAPDisplayName)) {
-                       if (schema_class->systemPossibleInferiors == NULL) {
-                               schema_class->systemPossibleInferiors = const_str_list(str_list_make_empty(schema_class));
+                       if (sys_poss_inf == NULL) {
+                               sys_poss_inf = const_str_list(str_list_make_empty(schema_class));
                        }
-                       schema_class->systemPossibleInferiors = str_list_add_const(schema_class->systemPossibleInferiors,
-                                                       c2->lDAPDisplayName);
+                       sys_poss_inf = str_list_add_const(sys_poss_inf,
+                                                         c2->lDAPDisplayName);
                }
        }
-       schema_class->systemPossibleInferiors = str_list_unique(schema_class->systemPossibleInferiors);
+       schema_class->systemPossibleInferiors = str_list_unique(sys_poss_inf);
+       schema_class->possibleInferiors = str_list_unique(poss_inf);
 }
 
 /*
@@ -347,7 +333,6 @@ int schema_fill_constructed(const struct dsdb_schema *schema)
 
        for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
                schema_fill_possible_inferiors(schema, schema_class);
-               schema_fill_system_possible_inferiors(schema, schema_class);
        }
 
        /* free up our internal cache elements */