Why JSF calls getters multiple times

This is caused by the nature of deferred expressions #{} (note that “legacy” standard expressions ${} behave exactly the same when Facelets is used instead of JSP). The deferred expression is not immediately evaluated, but created as a ValueExpression object and the getter method behind the expression is executed everytime when the code calls ValueExpression#getValue(). … Read more

Why is processing a sorted array faster than processing an unsorted array?

You are a victim of branch prediction fail. What is Branch Prediction? Consider a railroad junction: Image by Mecanismo, via Wikimedia Commons. Used under the CC-By-SA 3.0 license. Now for the sake of argument, suppose this is back in the 1800s – before long-distance or radio communication. You are the operator of a junction and … Read more

String vs. StringBuilder

Yes, the performance difference is significant. See the KB article “How to improve string concatenation performance in Visual C#”. I have always tried to code for clarity first, and then optimize for performance later. That’s much easier than doing it the other way around! However, having seen the enormous performance difference in my applications between … Read more