Skip to content

Commit

Permalink
parse: speed improved by refact
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewblond committed Jan 12, 2015
1 parent c410cc2 commit 6aea3cb
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/bem-naming.js
Expand Up @@ -131,19 +131,20 @@ BEMNaming.prototype.parse = function (str) {

if (!executed) return;

var elem = executed[5],
modName = executed[2] || executed[6],
modVal = executed[3] || executed[7],
notation = {};
var notation = {
block: executed[1] || executed[4]
},
elem = executed[5],
modName = executed[2] || executed[6];

if (modName && (modVal === undefined)) {
modVal = true;
}

notation.block = executed[1] || executed[4];
elem && (notation.elem = elem);
modName && (notation.modName = modName);
modVal && (notation.modVal = modVal);

if (modName) {
var modVal = executed[3] || executed[7];

notation.modName = modName;
notation.modVal = modVal === undefined ? true : modVal;
}

return notation;
};
Expand Down

0 comments on commit 6aea3cb

Please sign in to comment.