Skip to content

Commit 4510165

Browse files
jnarebgitster
authored andcommitted
gitweb.js: No need for inProgress in blame_incremental.js
JavaScript is single-threaded, so there is no need for protection against re-entrancy via inProgress variable. In particular calls to setInterval handler are stacked if handler doesn't finish before new interrupt (before new interval). The same happens with events - they are (hopefully) stacked if even handler didn't finish work. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2e987f9 commit 4510165

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

gitweb/static/js/blame_incremental.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,6 @@ function handleLine(commit, group) {
420420

421421
// ----------------------------------------------------------------------
422422

423-
var inProgress = false; // are we processing response
424-
425423
/**#@+
426424
* @constant
427425
*/
@@ -536,40 +534,36 @@ function processData(unprocessed, nextReadPos) {
536534
*
537535
* @param {XMLHttpRequest} xhr: XMLHttpRequest object
538536
*
539-
* @globals pollTimer, commits, inProgress
537+
* @globals pollTimer, commits
540538
*/
541539
function handleError(xhr) {
542540
errorInfo('Server error: ' +
543541
xhr.status + ' - ' + (xhr.statusText || 'Error contacting server'));
544542

545543
clearInterval(pollTimer);
546544
commits = {}; // free memory
547-
548-
inProgress = false;
549545
}
550546

551547
/**
552548
* Called after XMLHttpRequest finishes (loads)
553549
*
554550
* @param {XMLHttpRequest} xhr: XMLHttpRequest object (unused)
555551
*
556-
* @globals pollTimer, commits, inProgress
552+
* @globals pollTimer, commits
557553
*/
558554
function responseLoaded(xhr) {
559555
clearInterval(pollTimer);
560556

561557
fixColorsAndGroups();
562558
writeTimeInterval();
563559
commits = {}; // free memory
564-
565-
inProgress = false;
566560
}
567561

568562
/**
569563
* handler for XMLHttpRequest onreadystatechange event
570564
* @see startBlame
571565
*
572-
* @globals xhr, inProgress
566+
* @globals xhr
573567
*/
574568
function handleResponse() {
575569

@@ -609,13 +603,6 @@ function handleResponse() {
609603
return;
610604
}
611605

612-
// in case we were called before finished processing
613-
if (inProgress) {
614-
return;
615-
} else {
616-
inProgress = true;
617-
}
618-
619606
// extract new whole (complete) lines, and process them
620607
while (xhr.prevDataLength !== xhr.responseText.length) {
621608
if (xhr.readyState === 4 &&
@@ -633,8 +620,6 @@ function handleResponse() {
633620
xhr.prevDataLength === xhr.responseText.length) {
634621
responseLoaded(xhr);
635622
}
636-
637-
inProgress = false;
638623
}
639624

640625
// ============================================================

0 commit comments

Comments
 (0)