Skip to content

Commit

Permalink
fix: break out early (perf optimization)
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jun 12, 2022
1 parent 5468fe6 commit 2b816aa
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,9 @@ class SpamScanner {
// (we can assume that users would understand a different language sent to them is spam)
// (so we can assume that language is spoofed to bypass English, the most widely spoken)
//
if (
lang[0] &&
ISO_CODE_MAPPING[lang[0]] &&
lang[1] &&
lang[1] >= this.config.detectedLocaleOverrideProbability
) {
if (lang[0] && ISO_CODE_MAPPING[lang[0]] && lang[1]) {
// we don't want to check anything lower than our threshold
if (lang[1] < this.config.detectedLocaleOverrideProbability) break;
if (probability >= lang[1]) {
// exit early since we found a match that matched the passed locale
// eslint-disable-next-line max-depth
Expand Down

0 comments on commit 2b816aa

Please sign in to comment.