git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [JGIT PATCH] Avoid growing WorkingTreeIterator's path multiple times
@ 2009-07-01 22:45 Shawn O. Pearce
  0 siblings, 0 replies; only message in thread
From: Shawn O. Pearce @ 2009-07-01 22:45 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git, Constantine Plotnikov

If the current path buffer isn't big enough for the current file
name to be appended onto it, we can immediately grow it to the
correct target size by using the new ensurePathCapacity method.
This may save us from growing the buffer twice in rapid succession
if the path name component is really long, and the current buffer
is still the fairly small default size.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Constantine Plotnikov <constantine.plotnikov@gmail.com>
---
 .../spearce/jgit/treewalk/WorkingTreeIterator.java |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
index 836b01a..d4291ea 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
@@ -258,8 +258,7 @@ private void parseEntry() {
 		mode = e.getMode().getBits();
 
 		final int nameLen = e.encodedNameLen;
-		while (pathOffset + nameLen > path.length)
-			growPath(pathOffset);
+		ensurePathCapacity(pathOffset + nameLen, pathOffset);
 		System.arraycopy(e.encodedName, 0, path, pathOffset, nameLen);
 		pathLen = pathOffset + nameLen;
 	}
-- 
1.6.3.3.420.gd4b46

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-07-01 22:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-01 22:45 [JGIT PATCH] Avoid growing WorkingTreeIterator's path multiple times Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).