From 305ea9044896dfc390499790eed9ee318c4c4b58 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 7 Jul 2010 16:22:26 +0200 Subject: [PATCH] Do not fill in comboString when we are not using it. According to callgrind, blobwars was spending 4% of its time in enemyBulletCollisions(), calling snprintf() to fill in comboString. However, this string was only used when an enemy was killed to check against objectives. So now snprintf() has been moved to where it actually is being used, dropping time spent in that function by 3.8%. --- src/enemies.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/enemies.cpp b/src/enemies.cpp index 1e59f83..9c998c3 100644 --- a/src/enemies.cpp +++ b/src/enemies.cpp @@ -377,8 +377,6 @@ void enemyBulletCollisions(Entity *bullet) if ((bullet->owner == &player) || (bullet->owner == &engine.world) || (bullet->flags & ENT_BOSS)) { - snprintf(comboString, sizeof comboString, "Combo-%s", bullet->name); - if (Collision::collision(enemy, bullet)) { if (bullet->id != WP_LASER) @@ -458,6 +456,7 @@ void enemyBulletCollisions(Entity *bullet) checkCombo(); } + snprintf(comboString, sizeof comboString, "Combo-%s", bullet->name); checkObjectives(comboString, false); checkObjectives("Enemy", false); checkObjectives(enemy->name, false); @@ -505,6 +504,7 @@ void enemyBulletCollisions(Entity *bullet) { if (player.currentWeapon != &weapon[WP_LASER]) { + snprintf(comboString, sizeof comboString, "Combo-%s", bullet->name); checkCombo(); checkObjectives(comboString, false); } -- 2.39.5