]> Lady’s Gitweb - Gitweb/commitdiff
gitweb.js: No need for loop in blame_incremental's handleResponse()
authorJakub Narebski <redacted>
Fri, 27 May 2011 13:50:00 +0000 (15:50 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:31 +0000 (00:51 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
static/js/blame_incremental.js

index 22ed9bf908134ddabe12fee5c518370d48d1b6c3310ee0e521729bfd7d988b69..9040fbca71b5f1eebfaf416f4536ecf7fe1b12b74945a4975fef03b0e6be33e5 100644 (file)
@@ -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);
        }
 }
This page took 0.167158 seconds and 4 git commands to generate.