Skip to content
Browse files

Added 30 symbol limit exception.

Optimized array length and index lookups in loops.
Replaced name test against empty string with boolean test (empty string evaluates to false).
  • Loading branch information...
1 parent 424c8fa commit 21ab7802ac3b97555bbf6a967782b44602570b66 @xdissent committed Jun 10, 2011
Showing with 12 additions and 5 deletions.
  1. +12 −5 symbols.js
View
17 symbols.js
@@ -27,14 +27,21 @@ ig.Symbols = ig.Class.extend({
if (typeof classes == "undefined")
classes = [ig.Entity];
- var nameArray = names.split(" ");
+ var nameArray = names.split(" "),
+ nameArrayLen = nameArray.length;
+
+ if (nameArrayLen > 30) {
+ throw("Error: ig.Symbols allows a maximum of 30 symbol definitions.");
+ }
for(var i = 0; i < classes.length; i++){
var currentClass = classes[i];
- for(var j = 0; j < nameArray.length; j++){
- nameArray[j].replace(/^\s+|\s+$/g,"");
- if (nameArray[j] != "")
- currentClass[nameArray[j]] = 0x1 << j;
+ for(var j = 0; j < nameArrayLen; j++){
+ var name = nameArray[j];
+ name.replace(/^\s+|\s+$/g, "");
+ if (name) {
+ currentClass[name] = 0x1 << j;
+ }
}
}
ig.Symbols.instance = this;

0 comments on commit 21ab780

Please sign in to comment.
Something went wrong with that request. Please try again.