Skip to content

Commit e8dd0e4

Browse files
jnarebgitster
authored andcommitted
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 <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4510165 commit e8dd0e4

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

gitweb/static/js/blame_incremental.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,21 +603,16 @@ function handleResponse() {
603603
return;
604604
}
605605

606-
// extract new whole (complete) lines, and process them
607-
while (xhr.prevDataLength !== xhr.responseText.length) {
608-
if (xhr.readyState === 4 &&
609-
xhr.prevDataLength === xhr.responseText.length) {
610-
break;
611-
}
612606

607+
// extract new whole (complete) lines, and process them
608+
if (xhr.prevDataLength !== xhr.responseText.length) {
613609
xhr.prevDataLength = xhr.responseText.length;
614610
var unprocessed = xhr.responseText.substring(xhr.nextReadPos);
615611
xhr.nextReadPos = processData(unprocessed, xhr.nextReadPos);
616-
} // end while
612+
}
617613

618614
// did we finish work?
619-
if (xhr.readyState === 4 &&
620-
xhr.prevDataLength === xhr.responseText.length) {
615+
if (xhr.readyState === 4) {
621616
responseLoaded(xhr);
622617
}
623618
}

0 commit comments

Comments
 (0)