comparison src/org/tmatesoft/hg/internal/ManifestRevision.java @ 415:ee8264d80747

Explicit constant for regular file flags, access to flags for a given file revision
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 22 Mar 2012 18:54:11 +0100
parents 6dbbc53fc46d
children 9c9c442b5f2e
comparison
equal deleted inserted replaced
414:bb278ccf9866 415:ee8264d80747
55 public Nodeid nodeid(Path fname) { 55 public Nodeid nodeid(Path fname) {
56 return idsMap.get(fname); 56 return idsMap.get(fname);
57 } 57 }
58 58
59 public HgManifest.Flags flags(Path fname) { 59 public HgManifest.Flags flags(Path fname) {
60 return flagsMap.get(fname); 60 HgManifest.Flags f = flagsMap.get(fname);
61 return f == null ? HgManifest.Flags.RegularFile : f;
61 } 62 }
62 63
63 /** 64 /**
64 * @return identifier of the changeset this manifest revision corresponds to. 65 * @return identifier of the changeset this manifest revision corresponds to.
65 */ 66 */
83 } 84 }
84 if (idsPool != null) { 85 if (idsPool != null) {
85 nid = idsPool.unify(nid); 86 nid = idsPool.unify(nid);
86 } 87 }
87 idsMap.put(fname, nid); 88 idsMap.put(fname, nid);
88 if (flags != null) { 89 if (flags != HgManifest.Flags.RegularFile) {
89 // TreeMap$Entry takes 32 bytes. No reason to keep null for such price 90 // TreeMap$Entry takes 32 bytes. No reason to keep regular file attribute (in fact, no flags state)
91 // for such price
90 // Alternatively, Map<Path, Pair<Nodeid, Flags>> might come as a solution 92 // Alternatively, Map<Path, Pair<Nodeid, Flags>> might come as a solution
91 // however, with low rate of elements with flags this would consume more memory 93 // however, with low rate of elements with flags this would consume more memory
92 // than two distinct maps (sizeof(Pair) == 16). 94 // than two distinct maps (sizeof(Pair) == 16).
93 // Map<Pair>: n*(32+16) 95 // Map<Pair>: n*(32+16)
94 // 2 Maps: n*32 + m*32 <-- consumes more with m>n/2 96 // 2 Maps: n*32 + m*32 <-- consumes more with m>n/2