Skip to content
Advertisement

Does line length affect performance? [closed]

I have very long lines using lambda. Also, for example, I combined two loops with a condition into one line. Will such actions affect performance? Not for readability! Only I work with the code, and it reads great for me.

Example 1 (I have longer lines):

send = User.getUsers().stream().filter(it -> it.getPlayer().getWorld().equals(loc.getWorld())).filter(it -> it.getPlayer().getLocation().distance(loc) <= this.distance).collect(Collectors.toList());

Example 2:

for(int y = 0; y < this.yP; y++) for(int x = 0; x < this.xP; x++) if(x != y) this.collection.put(new RelativeLocation(x, y), new ImageData(image, x * 128 * 128));

Advertisement

Answer

Java is a compiled language, and line length is irrelevant to the compiler. However, it will affect the readability of your code. Longer lines are – generally – less readable, which makes it harder to understand your code, and therefor harder to maintain it.

In other words, don’t write code like this.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement