Skip to content

Commit

Permalink
remove unnecessary conditionals
Browse files Browse the repository at this point in the history
In code like this:

    if (arr.length > 0) {
      for (var i = 0; i < arr.length; ++i) { ... }
    }

The check is pointless and adds unnecessary indentation.
  • Loading branch information
Johannes Laire committed Mar 30, 2012
1 parent d3e4ad1 commit 4c7f9d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
8 changes: 3 additions & 5 deletions src/core/Matchers.js
Expand Up @@ -51,11 +51,9 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
} else { } else {
var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate; message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
if (matcherArgs.length > 0) { for (var i = 0; i < matcherArgs.length; i++) {
for (var i = 0; i < matcherArgs.length; i++) { if (i > 0) message += ",";
if (i > 0) message += ","; message += " " + jasmine.pp(matcherArgs[i]);
message += " " + jasmine.pp(matcherArgs[i]);
}
} }
message += "."; message += ".";
} }
Expand Down
32 changes: 16 additions & 16 deletions src/core/mock-timeout.js
Expand Up @@ -53,24 +53,24 @@ jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMil
} }
} }


if (funcsToRun.length > 0) { funcsToRun.sort(function(a, b) {
funcsToRun.sort(function(a, b) { return a.runAtMillis - b.runAtMillis;
return a.runAtMillis - b.runAtMillis; });
}); for (var i = 0; i < funcsToRun.length; ++i) {
for (var i = 0; i < funcsToRun.length; ++i) { try {
try { var funcToRun = funcsToRun[i];
var funcToRun = funcsToRun[i]; this.nowMillis = funcToRun.runAtMillis;
this.nowMillis = funcToRun.runAtMillis; funcToRun.funcToCall();
funcToRun.funcToCall(); if (funcToRun.recurring) {
if (funcToRun.recurring) { this.scheduleFunction(funcToRun.timeoutKey,
this.scheduleFunction(funcToRun.timeoutKey, funcToRun.funcToCall,
funcToRun.funcToCall, funcToRun.millis,
funcToRun.millis, true);
true);
}
} catch(e) {
} }
} catch(e) {
} }
}
if (funcsToRun.length > 0) {
this.runFunctionsWithinRange(oldMillis, nowMillis); this.runFunctionsWithinRange(oldMillis, nowMillis);
} }
}; };
Expand Down

0 comments on commit 4c7f9d1

Please sign in to comment.