Comparison of scala vs java performance in small code snippets