From 873a3084a9993f9dcf8d575563a6a018ed85dbb6 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 6 Apr 2016 22:48:59 +0200 Subject: Optimize nextExplosions --- src/ch/epfl/xblast/server/GameState.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index d648cef..77e91f2 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java @@ -232,13 +232,10 @@ public final class GameState { * @return the next explosion state */ private static List>> nextExplosions(List>> explosions0) { - List>> explosions1 = new ArrayList<>(); - for (Sq> explosion : explosions0) { - if (!explosion.tail().isEmpty()) { - explosions1.add(explosion.tail()); - } - } - return explosions1; + return explosions0.stream() + .map(Sq::tail) + .filter(s -> !s.isEmpty()) + .collect(Collectors.toList()); } /** -- cgit v1.2.3