Skip to content

Commit 580336e

Browse files
authored
AWTSettingsDialog: getDepths & getFrequencies use HashSet
1 parent 9979cc8 commit 580336e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

jme3-awt-dialogs/src/main/java/com/jme3/awt/AWTSettingsDialog.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ private String[] getWindowedResolutions(DisplayMode[] modes) {
914914
* Returns every possible bit depth for the given resolution.
915915
*/
916916
private static String[] getDepths(String resolution, DisplayMode[] modes) {
917-
List<String> depths = new ArrayList<>(4);
917+
Set<String> depths = new LinkedHashSet<>(4); // Use LinkedHashSet for uniqueness and order
918918
for (DisplayMode mode : modes) {
919919
int bitDepth = mode.getBitDepth();
920920
if (bitDepth == DisplayMode.BIT_DEPTH_MULTI) {
@@ -927,12 +927,8 @@ private static String[] getDepths(String resolution, DisplayMode[] modes) {
927927
continue;
928928
}
929929
String res = mode.getWidth() + " x " + mode.getHeight();
930-
if (!res.equals(resolution)) {
931-
continue;
932-
}
933-
String depth = bitDepth + " bpp";
934-
if (!depths.contains(depth)) {
935-
depths.add(depth);
930+
if (res.equals(resolution)) {
931+
depths.add(bitDepth + " bpp");
936932
}
937933
}
938934

0 commit comments

Comments
 (0)