Expose disposeBody() on RevCommit and RevTag

Applications that use a commit message once and do not
need it again can free the body to save memory. Expose
the disposeBody() methods to support this and use it in
pgm.Log which only visits each commit once.

Change-Id: I4142a0749c24f15386ee7fb119934a0432234de3
This commit is contained in:
Shawn Pearce 2015-05-10 10:42:09 -07:00
parent ca7daa5226
commit e4e947049f
3 changed files with 26 additions and 2 deletions

View File

@ -267,6 +267,7 @@ protected void show(final RevCommit c) throws Exception {
outw.print(s);
outw.println();
}
c.disposeBody();
outw.println();
if (showNotes(c))

View File

@ -609,7 +609,19 @@ public void reset() {
inDegree = 0;
}
final void disposeBody() {
/**
* Discard the message buffer to reduce memory usage.
* <p>
* After discarding the memory usage of the {@code RevCommit} is reduced to
* only the {@link #getTree()} and {@link #getParents()} pointers and the
* time in {@link #getCommitTime()}. Accessing other properties such as
* {@link #getAuthorIdent()}, {@link #getCommitterIdent()} or either message
* function requires reloading the buffer by invoking
* {@link RevWalk#parseBody(RevObject)}.
*
* @since 4.0
*/
public final void disposeBody() {
buffer = null;
}

View File

@ -270,7 +270,18 @@ public final String getTagName() {
return tagName;
}
final void disposeBody() {
/**
* Discard the message buffer to reduce memory usage.
* <p>
* After discarding the memory usage of the {@code RevTag} is reduced to
* only the {@link #getObject()} pointer and {@link #getTagName()}.
* Accessing other properties such as {@link #getTaggerIdent()} or either
* message function requires reloading the buffer by invoking
* {@link RevWalk#parseBody(RevObject)}.
*
* @since 4.0
*/
public final void disposeBody() {
buffer = null;
}
}