From 55720cfd4d0f0a35b54e552c45d17dbbb683d7b6 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 15 Aug 2011 07:22:41 +0800 Subject: [PATCH] Avoid exception try-catch on nominal path --- src/main/java/org/dynmap/AsynchronousQueue.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/dynmap/AsynchronousQueue.java b/src/main/java/org/dynmap/AsynchronousQueue.java index 8b9a854e..30e6781d 100644 --- a/src/main/java/org/dynmap/AsynchronousQueue.java +++ b/src/main/java/org/dynmap/AsynchronousQueue.java @@ -30,15 +30,10 @@ public class AsynchronousQueue { private T pop() { synchronized (lock) { - try { - T t = queue.removeFirst(); - if (!set.remove(t)) { - // This should never happen. - } - return t; - } catch (NoSuchElementException e) { - return null; - } + T t = queue.pollFirst(); + if(t != null) + set.remove(t); + return t; } }