Re: [PATCH] C version of git-count-objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 27, 2006 at 01:07:27PM -0700, Linus Torvalds wrote:
> 
> 
> On Thu, 27 Apr 2006, Peter Hagervall wrote:
> > > 
> > > To avoid appending the filename to the path before each lstat() I'd 
> > > guess.
> > 
> > Yes, that's pretty much the reason.
> 
> It's a bad reason, though.
> 
> For one thing, it just doesn't work. You'll have to chdir() back, and you 
> can't use ".." in case the user has set up some symlink thing. So you end 
> up doing other really strange things.
> 
> You can do this much more efficiently with something like this:
> 
> 	const char *obj = git_object_directory();
> 	int len = strlen(obj);

<snip>

> 				continue;
> 			strcpy(prefix + len, de->d_name);
> 			fd = open(prefix, O_RDONLY);
> 			.. check if it's ok, perhaps.. ?
> 			if (ok)
> 				nr++;
> 			close(fd);
> 		}
> 		return nr;
> 	}
> 
> and you're done. Efficient, and it's easy to add the endign to the 
> pathname, because you're passing in a buffer that is big enough, and 
> you're telling people where they should put their suffixes..

Thanks, I'll make a third stab at it tomorrow, if anyone is interested
that is?

	Peter
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]