4 ms·
Wondering if the similarity in performance of StringBuffer and StringBuilder has to do with lock elision. Can see if the compiler is doing this by examining the
by leothekim 10y ago
Wondering if the similarity in performance of StringBuffer and StringBuilder has to do with lock elision. Can see if the compiler is doing this by examining the generated bytecode.
- logn 10y agoIt might. There are other optimizations for synchronization introduced around Java 1.6 after wisdom around StringBuilder was already common. I think it's still safe to say StringBuilder at least can't hurt performance. More info: https://www.infoq.com/articles/java-threading-optimizations-p1 https://www.infoq.com/articles/java-threading-optimizations-... Separately, it's interesting to me chained calls can be more efficient. Personally I prefer these longer, multi-line type of statements from a readability perspective. So I'm happy it happens to be efficient.