From e1c50da7b47351c56ee5fd6764c34f7ccea3a417 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Mon, 9 Mar 2015 23:16:53 +0000 Subject: [PATCH] refreshMineCount performance improvement --- index.html | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index 2c571c1..9cee94f 100644 --- a/index.html +++ b/index.html @@ -371,25 +371,17 @@ function refreshMineCounts() { $('li.revealed:not(.mine)').each(function() { - $(this).text( - $(this).countMinesText() - ); + var mineCount = $(this).countMinesText(); + + $(this).text(mineCount); //remove "mines1" etc - - var mine = $(this).hasClass("mine"); - - $(this).removeAttr("class"); - - if (mine) { - $(this).addClass("mine"); - } else { - $(this).addClass( - "mines" + $(this).countMinesText() - ); - } - - $(this).addClass("revealed"); + $(this).attr( + 'class', + $(this).attr('class').replace( + /mines[0-9]/, "mines" + mineCount + ) + ); }); }