mirror of
https://github.com/lov3b/Schack.git
synced 2025-01-18 12:50:10 +01:00
snabbare att låta gc jobba än .clear()
This commit is contained in:
parent
9f10fc6dcd
commit
d209eb4b3c
@ -137,7 +137,7 @@ public class Board extends JPanel implements MouseListener {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
previouslyClickedPoint = new Point(clickedCoordinate);
|
previouslyClickedPoint = new Point(clickedCoordinate);
|
||||||
validMovesToDraw.clear();
|
validMovesToDraw = new ArrayList<>(); // Snabbare än .clear
|
||||||
}
|
}
|
||||||
|
|
||||||
// Om vi inte redan har valt en pjäs klickar vi på en pjäs
|
// Om vi inte redan har valt en pjäs klickar vi på en pjäs
|
||||||
@ -147,10 +147,10 @@ public class Board extends JPanel implements MouseListener {
|
|||||||
if (selectedPiece != null && selectedPiece.isWhite() == whitesTurn) {
|
if (selectedPiece != null && selectedPiece.isWhite() == whitesTurn) {
|
||||||
validMovesToDraw.addAll(selectedPiece.validMoves(pieces, true));
|
validMovesToDraw.addAll(selectedPiece.validMoves(pieces, true));
|
||||||
} else {
|
} else {
|
||||||
validMovesToDraw.clear();
|
validMovesToDraw = new ArrayList<>(); // Snabbare än .clear
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
validMovesToDraw.clear();
|
validMovesToDraw = new ArrayList<>(); // Snabbare än .clear
|
||||||
}
|
}
|
||||||
|
|
||||||
getParent().repaint();
|
getParent().repaint();
|
||||||
@ -174,7 +174,7 @@ public class Board extends JPanel implements MouseListener {
|
|||||||
}
|
}
|
||||||
if (attacked.supremeRuler) {
|
if (attacked.supremeRuler) {
|
||||||
inSchack = true;
|
inSchack = true;
|
||||||
validMovesToDraw.clear();
|
validMovesToDraw = new ArrayList<>(); // Snabbare än .clear
|
||||||
getParent().repaint();
|
getParent().repaint();
|
||||||
if (weCanMove) {
|
if (weCanMove) {
|
||||||
return SchackState.SCHACK;
|
return SchackState.SCHACK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user