Browse Source
A linear search is somewhat acceptable for only 4 recent chunks, but a HashMap based lookup would be better. The table will have 16 slots by default and given the hashCode() of ChunkKey is derived from the SHA-1 of the chunk, each chunk will fall into its own bucket within the table and thus evaluate only 1 entry during lookup instead of 4. Some users may also want to devote more memory to the recent chunks, in which case expanding this list to a longer length will help to reduce chunk faults, but would increase search time. Using a HashMap will help this code to scale to larger sizes better. Change-Id: Ia41b7a1cc69ad27b85749e3b74cbf8d0aa338044 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>stable-1.1
Shawn O. Pearce
14 years ago
1 changed files with 16 additions and 12 deletions
Loading…
Reference in new issue