comparison src/org/tmatesoft/hg/repo/Revlog.java @ 694:7efabe0cddcf

Speed up (a) file rename history to minimize file reads; (b) file.isCopy(int) to read metadata for few revisions at once (use pattern assumes earlier revisions are likely to be queried, too); (c) HgIgnore.isIgnored by caching matched initial fragments (to substitute more expensive Matcher.matches with cheaper HashMap.contains)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 05 Aug 2013 17:42:10 +0200
parents 32b0d19e8aba
children 053bb4397bf9
comparison
equal deleted inserted replaced
693:32b0d19e8aba 694:7efabe0cddcf
332 332
333 /** 333 /**
334 * EXPERIMENTAL CODE, DO NOT USE 334 * EXPERIMENTAL CODE, DO NOT USE
335 * 335 *
336 * Alternative revlog iteration 336 * Alternative revlog iteration
337 * There's an implicit ordering of inspectors. Less inspector needs, earlier its invocation occurs.
338 * E.g. ParentInspector goes after RevisionInspector. LinkRevisionInspector goes before RevisionInspector
337 * 339 *
338 * @param start 340 * @param start
339 * @param end 341 * @param end
340 * @param inspector 342 * @param inspector
341 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> 343 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
347 if (end == TIP) { 349 if (end == TIP) {
348 end = lastRev; 350 end = lastRev;
349 } 351 }
350 final RevisionInspector revisionInsp = Adaptable.Factory.getAdapter(inspector, RevisionInspector.class, null); 352 final RevisionInspector revisionInsp = Adaptable.Factory.getAdapter(inspector, RevisionInspector.class, null);
351 final ParentInspector parentInsp = Adaptable.Factory.getAdapter(inspector, ParentInspector.class, null); 353 final ParentInspector parentInsp = Adaptable.Factory.getAdapter(inspector, ParentInspector.class, null);
354 final LinkRevisionInspector linkRevInspector = Adaptable.Factory.getAdapter(inspector, LinkRevisionInspector.class, null);
352 final Nodeid[] allRevisions = parentInsp == null ? null : new Nodeid[end - _start + 1]; 355 final Nodeid[] allRevisions = parentInsp == null ? null : new Nodeid[end - _start + 1];
353 // next are to build set of parent indexes that are not part of the range iteration 356 // next are to build set of parent indexes that are not part of the range iteration
354 // i.e. those parents we need to read separately. See Issue 31 for details. 357 // i.e. those parents we need to read separately. See Issue 31 for details.
355 final int[] firstParentIndexes = parentInsp == null || _start == 0 ? null : new int[allRevisions.length]; 358 final int[] firstParentIndexes = parentInsp == null || _start == 0 ? null : new int[allRevisions.length];
356 final int[] secondParentIndexes = parentInsp == null || _start == 0 ? null : new int[allRevisions.length]; 359 final int[] secondParentIndexes = parentInsp == null || _start == 0 ? null : new int[allRevisions.length];
358 361
359 content.iterate(_start, end, false, new RevlogStream.Inspector() { 362 content.iterate(_start, end, false, new RevlogStream.Inspector() {
360 private int i = 0; 363 private int i = 0;
361 364
362 public void next(int revisionIndex, int actualLen, int baseRevIndex, int linkRevIndex, int parent1RevIndex, int parent2RevIndex, byte[] nodeid, DataAccess data) throws HgRuntimeException { 365 public void next(int revisionIndex, int actualLen, int baseRevIndex, int linkRevIndex, int parent1RevIndex, int parent2RevIndex, byte[] nodeid, DataAccess data) throws HgRuntimeException {
366 // FIXME refactor either as chain of RevlogStream.Inspector or an external AnyOf() runner not to keep everything
367 // in a single method
368 if (linkRevInspector != null) {
369 linkRevInspector.next(revisionIndex, linkRevIndex);
370 if (parentInsp == null && revisionInsp == null) {
371 return;
372 }
373 }
363 Nodeid nid = Nodeid.fromBinary(nodeid, 0); 374 Nodeid nid = Nodeid.fromBinary(nodeid, 0);
364 if (revisionInsp != null) { 375 if (revisionInsp != null) {
365 revisionInsp.next(revisionIndex, nid, linkRevIndex); 376 revisionInsp.next(revisionIndex, nid, linkRevIndex);
366 } 377 }
367 if (parentInsp != null) { 378 if (parentInsp != null) {
438 public interface RevisionInspector extends Inspector { 449 public interface RevisionInspector extends Inspector {
439 void next(int revisionIndex, Nodeid revision, int linkedRevisionIndex) throws HgRuntimeException; 450 void next(int revisionIndex, Nodeid revision, int linkedRevisionIndex) throws HgRuntimeException;
440 } 451 }
441 452
442 @Experimental 453 @Experimental
454 public interface LinkRevisionInspector extends Inspector {
455 void next(int revisionIndex, int linkedRevisionIndex) throws HgRuntimeException;
456 }
457
458 @Experimental
443 public interface ParentInspector extends Inspector { 459 public interface ParentInspector extends Inspector {
444 // XXX document whether parentX is -1 or a constant (BAD_REVISION? or dedicated?) 460 // XXX document whether parentX is -1 or a constant (BAD_REVISION? or dedicated?)
445 void next(int revisionIndex, Nodeid revision, int parent1, int parent2, Nodeid nidParent1, Nodeid nidParent2) throws HgRuntimeException; 461 void next(int revisionIndex, Nodeid revision, int parent1, int parent2, Nodeid nidParent1, Nodeid nidParent2) throws HgRuntimeException;
446 } 462 }
447 463