From 18aa0609ca1114e5d897077332ba58e5a22c9775 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sat, 5 Sep 2009 22:05:18 +0000 Subject: [PATCH] fix for caching of word hash computation git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6299 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/document/Word.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/de/anomic/document/Word.java b/source/de/anomic/document/Word.java index b9c5fea96..4c15e9c25 100644 --- a/source/de/anomic/document/Word.java +++ b/source/de/anomic/document/Word.java @@ -83,14 +83,15 @@ public class Word { // create a word hash public static final byte[] word2hash(final String word) { - byte[] h = hashCache.get(word); + String wordlc = word.toLowerCase(Locale.ENGLISH); + byte[] h = hashCache.get(wordlc); if (h != null) return h; synchronized(hashCache) { - h = hashCache.get(word); // we must test that again because another thread may have written the value in between + h = hashCache.get(wordlc); // we must test that again because another thread may have written the value in between if (h != null) return h; - h = Base64Order.enhancedCoder.encodeSubstring(Digest.encodeMD5Raw(word.toLowerCase(Locale.ENGLISH)), yacySeedDB.commonHashLength); + h = Base64Order.enhancedCoder.encodeSubstring(Digest.encodeMD5Raw(wordlc), yacySeedDB.commonHashLength); assert h[2] != '@'; - hashCache.put(word, h); // prevent expensive MD5 computation and encoding + hashCache.put(wordlc, h); // prevent expensive MD5 computation and encoding } return h; }