Browse Source

RevWalk: Don't reset ObjectReader when stopping

Applications like UploadPack reset() and reuse the same RevWalk
multiple times in very rapid succession.  Releasing the ObjectReader's
internal state on each use, only to allocate it again on the next
cycle kills performance if the ObjectReader has internal caches, or
even if the Inflater gets returned and pulled from the InflaterCache
too frequently.

Making releasing the ObjectReader the application's responsibility
when it is done with the RevWalk, which most already do by wrapping
their loop in a try/finally block.

Change-Id: I3ad188a719e8d7f6bf27d1a7ca16d465534713f4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.12
Shawn O. Pearce 14 years ago
parent
commit
bc1af8459e
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PendingGenerator.java
  2. 1
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java

3
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PendingGenerator.java

@ -129,8 +129,6 @@ class PendingGenerator extends Generator {
final RevCommit c = pending.next(); final RevCommit c = pending.next();
if (c == null) { if (c == null) {
walker.reader.walkAdviceEnd(); walker.reader.walkAdviceEnd();
if (!(walker instanceof ObjectWalk))
walker.reader.release();
return null; return null;
} }
@ -179,7 +177,6 @@ class PendingGenerator extends Generator {
} }
} catch (StopWalkException swe) { } catch (StopWalkException swe) {
walker.reader.walkAdviceEnd(); walker.reader.walkAdviceEnd();
walker.reader.release();
pending.clear(); pending.clear();
return null; return null;
} }

1
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java

@ -1181,7 +1181,6 @@ public class RevWalk implements Iterable<RevCommit> {
} }
} }
reader.release();
roots.clear(); roots.clear();
queue = new DateRevQueue(); queue = new DateRevQueue();
pending = new StartGenerator(this); pending = new StartGenerator(this);

Loading…
Cancel
Save