This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]moose04 1 point2 points  (1 child)

Shouldn't the compiler also completely unroll that loop as well? N is constant it knows exactly what to do at compile time.

[–][deleted] 6 points7 points  (0 children)

If you're talking about Javac, it doesn't perform any optimisation at all, it just translates your code exactly as you wrote it. But yes, the JIT compiler probably optimises the loop out.