From: Jakub Narebski Date: Fri, 27 May 2011 13:50:00 +0000 (+0200) Subject: gitweb.js: No need for loop in blame_incremental's handleResponse() X-Git-Url: https://git.ladys.computer/Gitweb/commitdiff_plain/ff3cde0cc388488d18aaee73fffa400e3daa35d77ebc2c52e49c32c48a6a5834?ds=inline gitweb.js: No need for loop in blame_incremental's handleResponse() JavaScript is single-threaded, so there is no need for protecting against changes to XMLHttpRequest object behind event handler back. Therefore there is no need for loop that was here in case `xhr' got new changes while processing current changes. This should make code a bit more clear. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- diff --git a/static/js/blame_incremental.js b/static/js/blame_incremental.js index 22ed9bf..9040fbc 100644 --- a/static/js/blame_incremental.js +++ b/static/js/blame_incremental.js @@ -603,21 +603,16 @@ function handleResponse() { return; } - // extract new whole (complete) lines, and process them - while (xhr.prevDataLength !== xhr.responseText.length) { - if (xhr.readyState === 4 && - xhr.prevDataLength === xhr.responseText.length) { - break; - } + // extract new whole (complete) lines, and process them + if (xhr.prevDataLength !== xhr.responseText.length) { xhr.prevDataLength = xhr.responseText.length; var unprocessed = xhr.responseText.substring(xhr.nextReadPos); xhr.nextReadPos = processData(unprocessed, xhr.nextReadPos); - } // end while + } // did we finish work? - if (xhr.readyState === 4 && - xhr.prevDataLength === xhr.responseText.length) { + if (xhr.readyState === 4) { responseLoaded(xhr); } }