Skip to content

Commit

Permalink
�Chore: rewrite parseListConfig for a small perf gain. (#9300)
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add authored and not-an-aardvark committed Sep 15, 2017
1 parent ce1f084 commit 12388d4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/linter.js
Expand Up @@ -146,17 +146,15 @@ function parseJsonConfig(string, location) {
*/
function parseListConfig(string) {
const items = {};
const reg = /[\w\-/]+/g;
const elementMatches = string.match(reg);

// Collapse whitespace around ,
string = string.replace(/\s*,\s*/g, ",");
if (elementMatches) {
elementMatches.forEach(name => {
items[name] = true;
});
}

string.split(/,+/).forEach(name => {
name = name.trim();
if (!name) {
return;
}
items[name] = true;
});
return items;
}

Expand Down

0 comments on commit 12388d4

Please sign in to comment.