Skip to content

Commit bafcd54

Browse files
committed
minor changes
1 parent e6ac72b commit bafcd54

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

core/src/processing/core/PApplet.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -2635,17 +2635,11 @@ protected void handleKeyEvent(KeyEvent event) {
26352635
keyPressed = true;
26362636
keyPressed(keyEvent);
26372637
}
2638-
case KeyEvent.RELEASE -> {
2639-
List<Long> hashesToRemove = new ArrayList<>();
2640-
for (Long hash : pressedKeys) {
2641-
int storedKeyCode = (int)(hash >> Character.SIZE);
2642-
if (storedKeyCode == keyCode) {
2643-
hashesToRemove.add(hash);
2644-
}
2645-
}
2646-
2647-
pressedKeys.removeAll(hashesToRemove);
2648-
2638+
case KeyEvent.RELEASE -> {
2639+
pressedKeys.removeIf(hash -> {
2640+
int pressedKeyCode = (int)(hash >> Character.SIZE);
2641+
return pressedKeyCode == keyCode;
2642+
});
26492643
keyPressed = !pressedKeys.isEmpty();
26502644
keyReleased(keyEvent);
26512645
}

core/test/processing/core/PAppletKeyEventTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void testShiftAndLetterSequence() {
4545
applet.handleKeyEvent(releaseShift);
4646

4747
Assert.assertFalse("keyPressed should be false after all keys released", applet.keyPressed);
48-
Assert.assertEquals("pressedKeys should be empty", true, applet.pressedKeys.isEmpty());
48+
Assert.assertTrue("pressedKeys should be empty", applet.pressedKeys.isEmpty());
4949
}
5050

5151
@Test
@@ -81,7 +81,7 @@ public void testAltAndLetterSequence() {
8181
applet.handleKeyEvent(releaseAlt);
8282

8383
Assert.assertFalse("keyPressed should be false after all keys released", applet.keyPressed);
84-
Assert.assertEquals("pressedKeys should be empty", true, applet.pressedKeys.isEmpty());
84+
Assert.assertTrue("pressedKeys should be empty", applet.pressedKeys.isEmpty());
8585
}
8686

8787
@Test

0 commit comments

Comments
 (0)