comparison mercurial/revlog.py @ 4990:4491125c0f21

revlogio: speed up parsing - precalcuate ending offset - pull some variables into local scope - separate inline and out of line code paths
author Matt Mackall <mpm@selenic.com>
date Mon, 23 Jul 2007 20:44:08 -0500
parents 1aaed3d69772
children 9c8c42bcf17a
comparison
equal deleted inserted replaced
4989:1aaed3d69772 4990:4491125c0f21
358 index = [] 358 index = []
359 nodemap = {nullid: nullrev} 359 nodemap = {nullid: nullrev}
360 n = off = 0 360 n = off = 0
361 # if we're not using lazymap, always read the whole index 361 # if we're not using lazymap, always read the whole index
362 data = fp.read() 362 data = fp.read()
363 l = len(data) 363 l = len(data) - s
364 unpack = struct.unpack
365 append = index.append
364 if inline: 366 if inline:
365 cache = (0, data) 367 cache = (0, data)
366 while off + s <= l: 368 while off <= l:
367 e = struct.unpack(indexformatng, data[off:off + s]) 369 e = unpack(indexformatng, data[off:off + s])
368 index.append(e) 370 nodemap[e[7]] = n
369 nodemap[e[7]] = n 371 append(e)
370 n += 1 372 n += 1
371 off += s
372 if inline:
373 if e[1] < 0: 373 if e[1] < 0:
374 break 374 break
375 off += e[1] 375 off += e[1] + s
376 else:
377 while off <= l:
378 e = unpack(indexformatng, data[off:off + s])
379 nodemap[e[7]] = n
380 append(e)
381 n += 1
382 off += s
376 383
377 e = list(index[0]) 384 e = list(index[0])
378 type = gettype(e[0]) 385 type = gettype(e[0])
379 e[0] = offset_type(0, type) 386 e[0] = offset_type(0, type)
380 index[0] = e 387 index[0] = e