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>
This commit is contained in:
Jakub Narebski
2011-05-27 15:49:59 +02:00
committed by Junio C Hamano
parent 2e987f9240
commit 4510165934

View File

@@ -420,8 +420,6 @@ function handleLine(commit, group) {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
var inProgress = false; // are we processing response
/**#@+ /**#@+
* @constant * @constant
*/ */
@@ -536,7 +534,7 @@ function processData(unprocessed, nextReadPos) {
* *
* @param {XMLHttpRequest} xhr: XMLHttpRequest object * @param {XMLHttpRequest} xhr: XMLHttpRequest object
* *
* @globals pollTimer, commits, inProgress * @globals pollTimer, commits
*/ */
function handleError(xhr) { function handleError(xhr) {
errorInfo('Server error: ' + errorInfo('Server error: ' +
@@ -544,8 +542,6 @@ function handleError(xhr) {
clearInterval(pollTimer); clearInterval(pollTimer);
commits = {}; // free memory commits = {}; // free memory
inProgress = false;
} }
/** /**
@@ -553,7 +549,7 @@ function handleError(xhr) {
* *
* @param {XMLHttpRequest} xhr: XMLHttpRequest object (unused) * @param {XMLHttpRequest} xhr: XMLHttpRequest object (unused)
* *
* @globals pollTimer, commits, inProgress * @globals pollTimer, commits
*/ */
function responseLoaded(xhr) { function responseLoaded(xhr) {
clearInterval(pollTimer); clearInterval(pollTimer);
@@ -561,15 +557,13 @@ function responseLoaded(xhr) {
fixColorsAndGroups(); fixColorsAndGroups();
writeTimeInterval(); writeTimeInterval();
commits = {}; // free memory commits = {}; // free memory
inProgress = false;
} }
/** /**
* handler for XMLHttpRequest onreadystatechange event * handler for XMLHttpRequest onreadystatechange event
* @see startBlame * @see startBlame
* *
* @globals xhr, inProgress * @globals xhr
*/ */
function handleResponse() { function handleResponse() {
@@ -609,13 +603,6 @@ function handleResponse() {
return; return;
} }
// in case we were called before finished processing
if (inProgress) {
return;
} else {
inProgress = true;
}
// extract new whole (complete) lines, and process them // extract new whole (complete) lines, and process them
while (xhr.prevDataLength !== xhr.responseText.length) { while (xhr.prevDataLength !== xhr.responseText.length) {
if (xhr.readyState === 4 && if (xhr.readyState === 4 &&
@@ -633,8 +620,6 @@ function handleResponse() {
xhr.prevDataLength === xhr.responseText.length) { xhr.prevDataLength === xhr.responseText.length) {
responseLoaded(xhr); responseLoaded(xhr);
} }
inProgress = false;
} }
// ============================================================ // ============================================================