Avoid exception try-catch on nominal path

This commit is contained in:
Mike Primm 2011-08-15 07:22:41 +08:00 committed by mikeprimm
parent 4cb5b9a956
commit 55720cfd4d

View File

@ -30,15 +30,10 @@ public class AsynchronousQueue<T> {
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;
}
}