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 exte synchronized (cache) { ReferenceContainer 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); + } } }