]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move switch to array lookup
authorAlan T. DeKok <aland@freeradius.org>
Sun, 16 Jul 2023 02:00:29 +0000 (22:00 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 16 Jul 2023 02:00:29 +0000 (22:00 -0400)
src/lib/util/pair.c

index 4e1cb793c2d0ced5f83c3f8e0babf35a6e011a54..f49bc0ad14623478cbe2e39b856646eabadd3c77 100644 (file)
@@ -550,6 +550,7 @@ fr_pair_t *fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
        if (!n) return NULL;
 
        n->op = vp->op;
+
        /*
         *      Copy the unknown attribute hierarchy
         */
@@ -561,22 +562,18 @@ fr_pair_t *fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
                }
        }
 
-
        /*
         *      Groups are special.
         */
-       switch (n->da->type) {
-       case FR_TYPE_STRUCTURAL:
+       if (fr_type_is_structural(n->da->type)) {
                if (fr_pair_list_copy(n, &n->vp_group, &vp->vp_group) < 0) {
                        talloc_free(n);
                        return NULL;
                }
-               return n;
 
-       default:
-               break;
+       } else {
+               fr_value_box_copy(n, &n->data, &vp->data);
        }
-       fr_value_box_copy(n, &n->data, &vp->data);
 
        return n;
 }