Revision 5545f057d4684de99feca0ca480297e3d71fb812 authored by Jeff King on 22 February 2016, 22:44:50 UTC, committed by Junio C Hamano on 22 February 2016, 22:51:09 UTC
We have two variants of this function, one that takes a
string and one that takes a ptr/len combo. But we only call
the latter with the length of a NUL-terminated string, so
our first simplification is to drop it in favor of the
string variant.

Since we know we have a string, we can also replace the
manual memory computation with a call to alloc_ref().

Furthermore, we can rely on get_oid_hex() to complain if it
hits the end of the string. That means we can simplify the
check for "<sha1> <ref>" versus just "<ref>". Rather than
manage the ptr/len pair, we can just bump the start of our
string forward. The original code over-allocated based on
the original "namelen" (which wasn't _wrong_, but was simply
wasteful and confusing).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a78c188
History
File Mode Size
files-backend.c -rw-r--r-- 95.3 KB
refs-internal.h -rw-r--r-- 6.3 KB

back to top