Show More
@@ -135,9 +135,9 b' class lazyparser(object):' | |||
|
135 | 135 | for x in xrange(lend): |
|
136 | 136 | if self.index[i + x] == None: |
|
137 | 137 | b = data[off : off + self.s] |
|
138 | e = struct.unpack(self.format, b) | |
|
139 | self.index[i + x] = e | |
|
140 |
self.map[ |
|
|
138 | self.index[i + x] = b | |
|
139 | n = b[self.shaoffset:self.shaoffset + 20] | |
|
140 | self.map[n] = i + x | |
|
141 | 141 | off += self.s |
|
142 | 142 | |
|
143 | 143 | def findnode(self, node): |
@@ -218,7 +218,10 b' class lazyindex(object):' | |||
|
218 | 218 | self.p.loadindex(pos) |
|
219 | 219 | return self.p.index[pos] |
|
220 | 220 | def __getitem__(self, pos): |
|
221 |
ret |
|
|
221 | ret = self.p.index[pos] or self.load(pos) | |
|
222 | if isinstance(ret, str): | |
|
223 | ret = struct.unpack(self.p.indexformat, ret) | |
|
224 | return ret | |
|
222 | 225 | def __setitem__(self, pos, item): |
|
223 | 226 | self.p.index[pos] = item |
|
224 | 227 | def __delitem__(self, pos): |
@@ -242,11 +245,13 b' class lazymap(object):' | |||
|
242 | 245 | def __iter__(self): |
|
243 | 246 | yield nullid |
|
244 | 247 | for i in xrange(self.p.l): |
|
245 | try: | |
|
246 | yield self.p.index[i][-1] | |
|
247 | except: | |
|
248 | ret = self.p.index[i] | |
|
249 | if not ret: | |
|
248 | 250 | self.p.loadindex(i) |
|
249 |
|
|
|
251 | ret = self.p.index[i] | |
|
252 | if isinstance(ret, str): | |
|
253 | ret = struct.unpack(self.p.indexformat, ret) | |
|
254 | yield ret[-1] | |
|
250 | 255 | def __getitem__(self, key): |
|
251 | 256 | try: |
|
252 | 257 | return self.p.map[key] |
General Comments 0
You need to be logged in to leave comments.
Login now