Author: toad
Date: 2008-07-29 18:52:00 +0000 (Tue, 29 Jul 2008)
New Revision: 21490
Modified:
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
Log:
Slight optimisation
Modified:
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
2008-07-29 18:42:44 UTC (rev 21489)
+++
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
2008-07-29 18:52:00 UTC (rev 21490)
@@ -796,13 +796,29 @@
}
public long countQueuedRequests(ObjectContainer container) {
- ObjectSet pending = container.query(new Predicate() {
- public boolean match(PendingKeyItem item) {
- if(item.nodeDBHandle == nodeDBHandle) return
true;
- return false;
+// ObjectSet pending = container.query(new Predicate() {
+// public boolean match(PendingKeyItem item) {
+// if(item.nodeDBHandle == nodeDBHandle) return
true;
+// return false;
+// }
+// });
+// return pending.size();
+ // If we just ask for the set of all PendingKeyItem's, we can
+ // filter them manually, and the query doesn't need to allocate
any
+ // significant amount of RAM - it just remembers to return the
class
+ // index.
+ ObjectSet pending = container.query(PendingKeyItem.class);
+ long total = 0;
+ while(pending.hasNext()) {
+ PendingKeyItem item = (PendingKeyItem) pending.next();
+ if(item.nodeDBHandle != nodeDBHandle) {
+ container.deactivate(item, 1);
+ continue;
}
- });
- return pending.size();
+ container.deactivate(item, 1);
+ total++;
+ }
+ return total;
}
protected boolean inPendingKeys(GotKeyListener req, final Key key,
ObjectContainer container) {