I have a function that corrects capitalization for a list of unusually capitalized words:
var line = "some long string of text";
["AppleScript", "Bluetooth", "DivX", "FireWire", "GarageBand",
"iPhone", "iTunes", "iWeb", "iWork", "JavaScript", "jQuery", "MacBook",
"MySQL", "PowerBook", "PowerPoint", "QuickTime", "TextEdit", "TextMate",
// ...
"Wi-Fi", "Xcode", "Xserve", "XMLHttpRequest"].forEach(function(name) {
line = line.replace(RegExp(name, "gi"), name);
});
Now the problem I am facing is that most input strings will contain on average between 0 and 3 of these words. Obviously now I am doing dozens (and potentially hundreds; that array has an uncanny tendency to grow over time) of function calls which essentially do nothing.
How can I make this code faster and get rid of the unnecessary function calls?
Example input:
My iphone application has a user form under UIViewController. When I start application again some of my UIView changes its positions and sizes. (These UIViews depend on keyboard position) Somewhere is definitely my fault. I try to figure what is going on when application starts again from background and where the UIView changes can be done.