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>

Jakub Narebski committed May 27, 2011 at 15:49 UTC 4510165934eba7be94dea822e2fb1cfa89e70ca3
1 file changed +3 -18
gitweb/static/js/blame_incremental.js
+3 -18
@@ -420,8 +420,6 @@ function handleLine(commit, group) {
420
421 // ----------------------------------------------------------------------
422
423 -var inProgress = false; // are we processing response
424 -
423 /**#@+
424 * @constant
425 */
@@ -536,7 +534,7 @@ function processData(unprocessed, nextReadPos) {
534 *
535 * @param {XMLHttpRequest} xhr: XMLHttpRequest object
536 *
539 - * @globals pollTimer, commits, inProgress
537 + * @globals pollTimer, commits
538 */
539 function handleError(xhr) {
540 errorInfo('Server error: ' +
@@ -544,8 +542,6 @@ function handleError(xhr) {
542
543 clearInterval(pollTimer);
544 commits = {}; // free memory
547 -
548 - inProgress = false;
545 }
546
547 /**
@@ -553,7 +549,7 @@ function handleError(xhr) {
549 *
550 * @param {XMLHttpRequest} xhr: XMLHttpRequest object (unused)
551 *
556 - * @globals pollTimer, commits, inProgress
552 + * @globals pollTimer, commits
553 */
554 function responseLoaded(xhr) {
555 clearInterval(pollTimer);
@@ -561,15 +557,13 @@ function responseLoaded(xhr) {
557 fixColorsAndGroups();
558 writeTimeInterval();
559 commits = {}; // free memory
564 -
565 - inProgress = false;
560 }
561
562 /**
563 * handler for XMLHttpRequest onreadystatechange event
564 * @see startBlame
565 *
572 - * @globals xhr, inProgress
566 + * @globals xhr
567 */
568 function handleResponse() {
569
@@ -609,13 +603,6 @@ function handleResponse() {
603 return;
604 }
605
612 - // in case we were called before finished processing
613 - if (inProgress) {
614 - return;
615 - } else {
616 - inProgress = true;
617 - }
618 -
606 // extract new whole (complete) lines, and process them
607 while (xhr.prevDataLength !== xhr.responseText.length) {
608 if (xhr.readyState === 4 &&
@@ -633,8 +620,6 @@ function handleResponse() {
620 xhr.prevDataLength === xhr.responseText.length) {
621 responseLoaded(xhr);
622 }
636 -
637 - inProgress = false;
623 }
624
625 // ============================================================