From 7cedc4c9dd24724ad2e97277932d993d09ae8e60 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 4 Aug 2020 19:07:25 +0200 Subject: [PATCH] quick performance improvement for scale_number --- src/kernel/unit.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 4b45ccea4..bd8e91d7e 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -974,6 +974,12 @@ void remove_skill(unit * u, skill_t sk) } } +static void remove_skills(unit * u) { + free(u->skills); + u->skills = NULL; + u->skill_size = 0; +} + skill *add_skill(unit * u, skill_t sk) { skill *sv; @@ -1588,10 +1594,7 @@ void scale_number(unit * u, int n) } } if (u->number == 0 || n == 0) { - skill_t sk; - for (sk = 0; sk < MAXSKILLS; sk++) { - remove_skill(u, sk); - } + remove_skills(u); } set_number(u, n);