Sunday, October 12, 2008

A quick fix to vroom.js replaceFirst and replaceAll functions

Replace the functions VroomUtils.replaceFirst(...) and VroomUtils.replaceAll(...) with following to improve the performance:

VroomUtils.replaceFirst = function (text, s, t) {
if (text !== null && text.indexOf(s) !== -1) {
text = text.replace(s, t);
}
return text;
};

VroomUtils.replaceAll = function (text, s, t) {
if (text !== null) {
while(text.indexOf(s) !== -1) {
text = text.replace(s, t);
}
}
return text;
};