From 1bdd68a95ba30896c5713a0b5689635ffc8dcc1f Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 1 Jul 2013 13:58:16 -0700 Subject: j3dcore: change to ArrayList in the async error handling code This is not a high-rate path, so ArrayList should be fine without too many resizes. Try and make up for it by allocating an array of sufficient size up front to avoid reflection inside the toArray method. Signed-off-by: Harvey Harrison --- src/classes/share/javax/media/j3d/NotificationThread.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/classes/share') diff --git a/src/classes/share/javax/media/j3d/NotificationThread.java b/src/classes/share/javax/media/j3d/NotificationThread.java index b552e8d..630f37c 100644 --- a/src/classes/share/javax/media/j3d/NotificationThread.java +++ b/src/classes/share/javax/media/j3d/NotificationThread.java @@ -26,7 +26,7 @@ package javax.media.j3d; -import java.util.LinkedList; +import java.util.ArrayList; /** * The NotificationThread class is used for asynchronous error notification, @@ -42,7 +42,7 @@ class NotificationThread extends Thread { private boolean waiting = false; private boolean ready = false; - private LinkedList notificationQueue = new LinkedList(); + private ArrayList notificationQueue = new ArrayList(); /** * Creates a new instance of NotificationThread @@ -64,9 +64,10 @@ class NotificationThread extends Thread { * Gets the list of queued notification messages */ private synchronized J3dNotification[] getNotifications() { - J3dNotification[] notifications = (J3dNotification[])notificationQueue.toArray(new J3dNotification[0]); + J3dNotification[] n = new J3dNotification[notificationQueue.size()]; + n = notificationQueue.toArray(n); notificationQueue.clear(); - return notifications; + return n; } /** -- cgit v1.2.3