]> source.dussan.org Git - jgit.git/commitdiff
RevWalk: Don't reset ObjectReader when stopping 33/2433/4
authorShawn O. Pearce <spearce@spearce.org>
Sun, 6 Feb 2011 09:15:33 +0000 (01:15 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 13 Feb 2011 21:43:11 +0000 (13:43 -0800)
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>
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PendingGenerator.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java

index d0a1a832fe2dd17c0294a8a19ce3c57ab2889ac0..f1624070dfc322e256789d1b1e16f383b771231a 100644 (file)
@@ -129,8 +129,6 @@ class PendingGenerator extends Generator {
                                final RevCommit c = pending.next();
                                if (c == null) {
                                        walker.reader.walkAdviceEnd();
-                                       if (!(walker instanceof ObjectWalk))
-                                               walker.reader.release();
                                        return null;
                                }
 
@@ -179,7 +177,6 @@ class PendingGenerator extends Generator {
                        }
                } catch (StopWalkException swe) {
                        walker.reader.walkAdviceEnd();
-                       walker.reader.release();
                        pending.clear();
                        return null;
                }
index 17cdb443c85d5bbd67e6b4875171c88cc19f5007..cdedacb730378eed4babf658c6667e333a208324 100644 (file)
@@ -1181,7 +1181,6 @@ public class RevWalk implements Iterable<RevCommit> {
                        }
                }
 
-               reader.release();
                roots.clear();
                queue = new DateRevQueue();
                pending = new StartGenerator(this);