optimized ipAddress parser

This commit is contained in:
Rob Garrison 2012-07-12 02:25:32 -05:00
parent 718ef4e79b
commit 3951345f69

View File

@ -1023,18 +1023,11 @@
return (/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/).test(s); return (/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/).test(s);
}, },
format: function(s, table) { format: function(s, table) {
var i, item, a = s.split("."), var i, a = s.split("."),
r = "", r = "",
l = a.length; l = a.length;
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
item = a[i]; r += ("00" + a[i]).slice(-3);
if (item.length === 1) {
r += "00" + item;
} else if (item.length === 2) {
r += "0" + item;
} else {
r += item;
}
} }
return ts.formatFloat(r, table); return ts.formatFloat(r, table);
}, },