git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [JGIT PATCH] Support for delegating tree iterators

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 1, 2009, 22:34 UTC
Message-ID
<20090701223448.GT11191@spearce.org>
In-Reply-To
<1246470772-4496-1-git-send-email-constantine.plotnikov@gmail.com>
Constantine Plotnikov <constantine.plotnikov@gmail.com> wrote:
Show 8 quoted lines
> This patch introduce some methods that simplify creation of tree
> iterators that wraps other iterators and which are located in
> other package. Such iterators need to efficiently access the
> name component of the path of wrapped iterator and wrapped bits.
> The patch also adds a method that ensuring that path buffer has
> a requried capacity when the required capacity is known in advance.
> 
> Signed-off-by: Constantine Plotnikov <constantine.plotnikov@gmail.com>
Thanks, two style nits, I fixed during apply:
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
index 2fe756e..50befbe 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
@@ -264,15 +264,13 @@ protected void growPath(final int len) {
 	 *            the amount of live bytes in path buffer
 	 */
 	protected void ensurePathCapacity(final int capacity, final int len) {
-		if(path.length >= capacity) {
+		if (path.length >= capacity)
 			return;
-		}
 		final byte[] o = path;
 		int current = o.length;
 		int newCapacity = current;
-		while(newCapacity < capacity && newCapacity > 0) {
+		while (newCapacity < capacity && newCapacity > 0)
 			newCapacity <<= 1;
-		}
 		setPathCapacity(newCapacity, len);
 	}
 
> ---
> Note that WorkingTreeIterator.parseEntry is possibly might be a good 
> place to use ensurePathCapacity(...) instead or growPath(...).

Yes.  I'll send a change shortly.
   
-- 
Shawn.
Previous: Constantine PlotnikovNext: Shawn O. Pearce
Message 2 of 4 in “Support for delegating tree iterators”
  1. Support for delegating tree iteratorsConstantine Plotnikov, Jul 1, 2009
  2. Shawn O. PearceJul 1, 2009
  3. Shawn O. PearceJul 1, 2009
  4. Robin RosenbergJul 2, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.