Avoid exception try-catch on nominal path
This commit is contained in:
parent
aa9a1f888d
commit
8c685d2fd8
1 changed files with 4 additions and 9 deletions
|
|
@ -30,15 +30,10 @@ public class AsynchronousQueue<T> {
|
||||||
|
|
||||||
private T pop() {
|
private T pop() {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
try {
|
T t = queue.pollFirst();
|
||||||
T t = queue.removeFirst();
|
if(t != null)
|
||||||
if (!set.remove(t)) {
|
set.remove(t);
|
||||||
// This should never happen.
|
return t;
|
||||||
}
|
|
||||||
return t;
|
|
||||||
} catch (NoSuchElementException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue