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