Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove unnecessary conditionals

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...
commit 4c7f9d1c86a160403db4e3e2be118eede2676a3e 1 parent d3e4ad1
@jlaire jlaire authored
Showing with 19 additions and 21 deletions.
  1. +3 −5 src/core/Matchers.js
  2. +16 −16 src/core/mock-timeout.js
View
8 src/core/Matchers.js
@@ -51,11 +51,9 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
} else {
var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
- if (matcherArgs.length > 0) {
- for (var i = 0; i < matcherArgs.length; i++) {
- if (i > 0) message += ",";
- message += " " + jasmine.pp(matcherArgs[i]);
- }
+ for (var i = 0; i < matcherArgs.length; i++) {
+ if (i > 0) message += ",";
+ message += " " + jasmine.pp(matcherArgs[i]);
}
message += ".";
}
View
32 src/core/mock-timeout.js
@@ -53,24 +53,24 @@ jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMil
}
}
- if (funcsToRun.length > 0) {
- funcsToRun.sort(function(a, b) {
- return a.runAtMillis - b.runAtMillis;
- });
- for (var i = 0; i < funcsToRun.length; ++i) {
- try {
- var funcToRun = funcsToRun[i];
- this.nowMillis = funcToRun.runAtMillis;
- funcToRun.funcToCall();
- if (funcToRun.recurring) {
- this.scheduleFunction(funcToRun.timeoutKey,
- funcToRun.funcToCall,
- funcToRun.millis,
- true);
- }
- } catch(e) {
+ funcsToRun.sort(function(a, b) {
+ return a.runAtMillis - b.runAtMillis;
+ });
+ for (var i = 0; i < funcsToRun.length; ++i) {
+ try {
+ var funcToRun = funcsToRun[i];
+ this.nowMillis = funcToRun.runAtMillis;
+ funcToRun.funcToCall();
+ if (funcToRun.recurring) {
+ this.scheduleFunction(funcToRun.timeoutKey,
+ funcToRun.funcToCall,
+ funcToRun.millis,
+ true);
}
+ } catch(e) {
}
+ }
+ if (funcsToRun.length > 0) {
this.runFunctionsWithinRange(oldMillis, nowMillis);
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.