~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/xml8.py

  • Committer: John Arbash Meinel
  • Date: 2008-12-10 18:29:35 UTC
  • mto: This revision was merged to the branch mainline in revision 3912.
  • Revision ID: john@arbash-meinel.com-20081210182935-dejc81qksqka717d
Do Inventory.add() optimizations, and determine 'best' results.

Show diffs side-by-side

added added

removed removed

Lines of Context:
368
368
        # Some timings for "repo.revision_trees(last_100_bzr_revs)"
369
369
        #   unmodified  4.1s
370
370
        #   using lru   3.5s
371
 
        #   using fifo  2.9s
 
371
        #   using fifo  2.83s
372
372
        #   lru._cache  2.8s
 
373
        #   dict        2.75s
373
374
        # Note that a cache of 10k nodes is more than sufficient to hold all of
374
375
        # the inventory for the last 100 revs.
 
376
        #   With inventory.add() optimizations, and not copying file entries,
 
377
        #   performance gets to 2.00s
375
378
        key = (file_id, revision)
376
379
        try:
377
380
            # We copy it, because some operatations may mutate it
378
 
            return _entry_cache[key].copy()
 
381
            cached_ie = _entry_cache[key]
379
382
        except KeyError:
380
383
            pass
 
384
        else:
 
385
            # Only copying directory entries drops us 2.85s => 2.35s
 
386
            if cached_ie.kind == 'directory':
 
387
                return cached_ie.copy()
 
388
            return cached_ie
 
389
            # return cached_ie.copy()
381
390
 
382
391
        kind = elt.tag
383
392
        if not InventoryEntry.versionable_kind(kind):
411
420
        else:
412
421
            raise errors.UnsupportedInventoryKind(kind)
413
422
        ie.revision = revision
414
 
        _entry_cache[key] = ie
 
423
        if revision is not None:
 
424
            _entry_cache[key] = ie
415
425
 
416
426
        return ie
417
427