From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org,
Constantine Plotnikov <constantine.plotnikov@gmail.com>
Subject: [JGIT PATCH] Avoid growing WorkingTreeIterator's path multiple times
Date: Wed, 1 Jul 2009 15:45:53 -0700 [thread overview]
Message-ID: <1246488353-16867-1-git-send-email-spearce@spearce.org> (raw)
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
reply other threads:[~2009-07-01 22:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1246488353-16867-1-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=constantine.plotnikov@gmail.com \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).