summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2013-07-01 13:58:16 -0700
committerHarvey Harrison <[email protected]>2013-07-01 13:58:16 -0700
commit1bdd68a95ba30896c5713a0b5689635ffc8dcc1f (patch)
tree09891defeaaa01fe4b6e3ceb1588cd403e0b9cfc
parent9abca359f5a9d3205ac8002c9817927266bd91ce (diff)
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 <[email protected]>
-rw-r--r--src/classes/share/javax/media/j3d/NotificationThread.java9
1 files changed, 5 insertions, 4 deletions
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<J3dNotification> notificationQueue = new ArrayList<J3dNotification>();
/**
* 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;
}
/**