login
Header Space

 
 

Re: [PATCH] name-rev: Fix non-shortest description

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jeff King <peff@...>
Cc: Uwe <ukleinek@...>, <git@...>, <gitster@...>
Date: Tuesday, August 28, 2007 - 7:02 am

Hi,

On Tue, 28 Aug 2007, Jeff King wrote:


Okay, I could have been clearer: make rev_name a linked list, where only 
the first contains the actual root of the name (i.e. "v2.6.22-rc1").  This 
can be made const char *, so that it is not allocated.

Then, like you described, you can have instances of rev_name, pointing to 
other instances of rev_name instead of a root.

And to speed up comparison (and to know whether to point to a rev_name or 
a const char *) you can store the number of merge traversals:

struct rev_name {
	union {
	 	/* root is used when traversals == 0, otherwise previous */
		struct rev_name *previous;
		const char *root;
	} p;
	int generation;
	int traversals;
}

Then comparison would be something like

	int cmp_name(struct rev_name *n1, struct rev_name *n2)
	{
		int result = 0;
		if (n1->traversals != n2->traversals)
			return n1->traversals - n2->traversals;
		do {
			if (n1->generation != n2->generation)
				result = n1->generation - n2->generation;
			n1 = n1->p.previous;
			n2 = n2->p.previous;
		} while (n1->traversals);
		return result;
	}

Name generation would be a bit more expensive, but then it is the 
operation which is called only rarely.

Ciao,
Dscho

	
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
name-rev does not show the shortest path, Uwe , (Thu Aug 23, 6:38 am)
[PATCH] name-rev: Fix non-shortest description, Johannes Schindelin, (Mon Aug 27, 7:37 am)
Re: [PATCH] name-rev: Fix non-shortest description, Jeff King, (Tue Aug 28, 4:20 am)
Re: [PATCH] name-rev: Fix non-shortest description, Johannes Schindelin, (Tue Aug 28, 5:15 am)
Re: [PATCH] name-rev: Fix non-shortest description, Jeff King, (Tue Aug 28, 5:25 am)
Re: [PATCH] name-rev: Fix non-shortest description, Johannes Schindelin, (Tue Aug 28, 6:03 am)
Re: [PATCH] name-rev: Fix non-shortest description, Jeff King, (Tue Aug 28, 6:26 am)
Re: [PATCH] name-rev: Fix non-shortest description, Johannes Schindelin, (Tue Aug 28, 7:02 am)
Re: [PATCH] name-rev: Fix non-shortest description, Jeff King, (Tue Aug 28, 7:11 am)
Re: [PATCH] name-rev: Fix non-shortest description, Johannes Schindelin, (Tue Aug 28, 7:28 am)
Re: [PATCH] name-rev: Fix non-shortest description, Jeff King, (Tue Aug 28, 7:34 am)
Re: [PATCH] name-rev: Fix non-shortest description, Johannes Schindelin, (Tue Aug 28, 4:39 am)
Re: [PATCH] name-rev: Fix non-shortest description, Jeff King, (Tue Aug 28, 5:00 am)
Re: [PATCH] name-rev: Fix non-shortest description, Jeff King, (Tue Aug 28, 5:26 am)
Re: name-rev does not show the shortest path, Julian Phillips, (Fri Aug 24, 7:55 am)
Re: name-rev does not show the shortest path, Julian Phillips, (Fri Aug 24, 11:21 am)
Re: name-rev does not show the shortest path, Junio C Hamano, (Fri Aug 24, 2:33 pm)
Re: name-rev does not show the shortest path, Johannes Schindelin, (Sat Aug 25, 11:04 am)
Re: name-rev does not show the shortest path, Jeff King, (Sun Aug 26, 5:23 am)
Re: name-rev does not show the shortest path, Johannes Schindelin, (Sun Aug 26, 11:38 am)
Re: name-rev does not show the shortest path, Jeff King, (Mon Aug 27, 5:24 am)
Re: name-rev does not show the shortest path, Johannes Schindelin, (Mon Aug 27, 5:57 am)
Re: name-rev does not show the shortest path, Johannes Schindelin, (Mon Aug 27, 7:18 am)
speck-geostationary