@@ -123,14 +123,10 @@ module internal Implementation =
123123// Read the tables written by FSYACC.
124124
125125type AssocTable ( elemTab : uint16 [], offsetTab : uint16 []) =
126- #if OLD_ CACHE
127- let cache = new Dictionary< int, int>( 2000 )
128- #else
129126let cacheSize = 7919 // the 1000'th prime
130127// Use a simpler hash table with faster lookup, but only one
131128// hash bucket per key.
132129let cache = Array.zeroCreate< int> ( cacheSize* 2 )
133- #endif
134130
135131member t.ReadAssoc ( minElemNum , maxElemNum , defaultValueOfAssoc , keyToFind ) =
136132// do a binary chop on the table
@@ -155,29 +151,18 @@ module internal Implementation =
155151assert ( rowNumber< 0x10000 )
156152assert ( keyToFind< 0x10000 )
157153let cacheKey = ( rowNumber<<< 16 ) ||| keyToFind
158- #if OLD_ CACHE
159- let mutable res = 0
160- let ok = cache.TryGetValue( cacheKey, & res)
161- if okthen res
162- else
163- #else
164- let cacheIdx = int32( uint32 cacheKey% uint32 cacheSize)
165- let cacheKey2 = cache.[ cacheIdx* 2 ]
166- let v = cache.[ cacheIdx* 2 + 1 ]
154+ let cacheIdx = ( int32( uint32 cacheKey% uint32 cacheSize)) * 2
155+ let cacheKey2 = cache.[ cacheIdx]
156+ let v = cache.[ cacheIdx+ 1 ]
167157if cacheKey= cacheKey2then v
168158else
169- #endif
170159let headOfTable = int offsetTab.[ rowNumber]
171160let firstElemNumber = headOfTable+ 1
172161let numberOfElementsInAssoc = int elemTab.[ headOfTable* 2 ]
173162let defaultValueOfAssoc = int elemTab.[ headOfTable* 2 + 1 ]
174163let res = t.ReadAssoc( firstElemNumber, firstElemNumber+ numberOfElementsInAssoc, defaultValueOfAssoc, keyToFind)
175- #if OLD_ CACHE
176- cache.[ cacheKey] <- res
177- #else
178- cache.[ cacheIdx* 2 ] <- cacheKey
179- cache.[ cacheIdx* 2 + 1 ] <- res
180- #endif
164+ cache.[ cacheIdx] <- cacheKey
165+ cache.[ cacheIdx+ 1 ] <- res
181166 res
182167
183168// Read all entries in the association table