Permalink
Browse files

Reduce unnecessary comparisons once there's an exact match.

  • Loading branch information...
1 parent 13a3249 commit 0fc27c99fcc0c4ce83bc405f5154c76d7aa67cc5 @derrickko derrickko committed Mar 24, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/jquery.mailcheck.js
View
@@ -62,14 +62,17 @@ var Kicksend = {
var closestDomain = null;
for (var i = 0; i < domains.length; i++) {
+ if (domain === domains[i]) {
+ return false;
+ }
dist = this.stringDistance(domain, domains[i]);
if (dist < minDist) {
minDist = dist;
closestDomain = domains[i];
}
}
- if (minDist <= this.threshold && closestDomain !== null && closestDomain !== domain) {
+ if (minDist <= this.threshold && closestDomain !== null) {
return closestDomain;
} else {
return false;

0 comments on commit 0fc27c9

Please sign in to comment.