comparison src/org/tmatesoft/hg/repo/HgDataFile.java @ 79:5f9635c01681

TreeMap are more effective when keys are unique
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 25 Jan 2011 02:26:06 +0100
parents c25c5c348d1b
children 61eedab3eb3e
comparison
equal deleted inserted replaced
78:c25c5c348d1b 79:5f9635c01681
18 18
19 import static org.tmatesoft.hg.repo.HgRepository.TIP; 19 import static org.tmatesoft.hg.repo.HgRepository.TIP;
20 20
21 import java.util.ArrayList; 21 import java.util.ArrayList;
22 import java.util.Collection; 22 import java.util.Collection;
23 import java.util.HashMap; 23 import java.util.TreeMap;
24 24
25 import org.tmatesoft.hg.core.Nodeid; 25 import org.tmatesoft.hg.core.Nodeid;
26 import org.tmatesoft.hg.core.Path; 26 import org.tmatesoft.hg.core.Path;
27 import org.tmatesoft.hg.internal.RevlogStream; 27 import org.tmatesoft.hg.internal.RevlogStream;
28 28
190 } 190 }
191 } 191 }
192 192
193 private static class Metadata { 193 private static class Metadata {
194 // XXX sparse array needed 194 // XXX sparse array needed
195 private final HashMap<Integer, Integer> offsets = new HashMap<Integer, Integer>(5); 195 private final TreeMap<Integer, Integer> offsets = new TreeMap<Integer, Integer>();
196 private final HashMap<Integer, MetadataEntry[]> entries = new HashMap<Integer, MetadataEntry[]>(5); 196 private final TreeMap<Integer, MetadataEntry[]> entries = new TreeMap<Integer, MetadataEntry[]>();
197 boolean known(int revision) { 197 boolean known(int revision) {
198 return offsets.containsKey(revision); 198 return offsets.containsKey(revision);
199 } 199 }
200 // since this is internal class, callers are supposed to ensure arg correctness (i.e. ask known() before) 200 // since this is internal class, callers are supposed to ensure arg correctness (i.e. ask known() before)
201 int dataOffset(int revision) { 201 int dataOffset(int revision) {