Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
commit-tree.c: check_valid() microoptimization.
author
Junio C Hamano
<junkio@cox.net>
Wed, 26 Apr 2006 23:55:25 +0000
(16:55 -0700)
committer
Junio C Hamano
<junkio@cox.net>
Wed, 26 Apr 2006 23:55:25 +0000
(16:55 -0700)
There is no point reading the whole object just to make sure it exists and
it is of the expected type. We added sha1_object_info() for such need
after this code was written, so use it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
commit-tree.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
e23d0b4
)
diff --git
a/commit-tree.c
b/commit-tree.c
index 2d8651894a20e752eb47e6da439ad3cee13c29c4..25958509703f7e46dc0b1a4bffd7be8ba2897cf9 100644
(file)
--- a/
commit-tree.c
+++ b/
commit-tree.c
@@
-45,14
+45,13
@@
static void add_buffer(char **bufp, unsigned int *sizep, const char *fmt, ...)
static void check_valid(unsigned char *sha1, const char *expect)
{
static void check_valid(unsigned char *sha1, const char *expect)
{
- void *buf;
char type[20];
char type[20];
- unsigned long size;
- buf = read_sha1_file(sha1, type, &size);
- if (!buf || strcmp(type, expect))
- die("%s is not a valid '%s' object", sha1_to_hex(sha1), expect);
- free(buf);
+ if (sha1_object_info(sha1, type, NULL))
+ die("%s is not a valid object", sha1_to_hex(sha1));
+ if (expect && strcmp(type, expect))
+ die("%s is not a valid '%s' object", sha1_to_hex(sha1),
+ expect);
}
/*
}
/*