Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Fix for http://forum.yacy-websuche.de/viewtopic.php?f=6&t=2334

hermens2fbc0696bf98
diff --git a/source/de/anomic/kelondro/text/ReferenceContainerCache.java b/source/de/anomic/kelondro/text/ReferenceContainerCache.java
index 51f2aa529..e5ca3c0dc 100644
--- a/source/de/anomic/kelondro/text/ReferenceContainerCache.java
+++ b/source/de/anomic/kelondro/text/ReferenceContainerCache.java
@@ -427,8 +427,15 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> exte
synchronized (cache) {
ReferenceContainer<ReferenceType> containerNew = cache.put(tha, container);
if (containerNew == null) return;
- container.putAllRecent(containerNew);
- cache.put(tha, container);
+ // Now merge the smaller container into the lager.
+ // The other way around can become very slow
+ if (container.size() >= containerNew.size()) {
+ container.putAllRecent(containerNew);
+ cache.put(tha, container);
+ } else {
+ containerNew.putAllRecent(container);
+ cache.put(tha, containerNew);
+ }
}
}