mirror of
https://github.com/git/git.git
synced 2026-08-08 17:11:48 +00:00
object-name: use hexval
We've open-coded a different implementation of parsing hex values here when we already have a perfectly good one in hexval. This implementation will almost certainly be slower because it isn't table-driven, unlike the other one, and since it's not constant time it has no other advantages either. To tidy things up and prepare for future work, switch to hexval in this case. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
5f2685d256
commit
7233f519c7
@@ -236,17 +236,10 @@ static int parse_oid_prefix(const char *name, int len,
|
||||
{
|
||||
for (int i = 0; i < len; i++) {
|
||||
unsigned char c = name[i];
|
||||
unsigned char val;
|
||||
if (c >= '0' && c <= '9') {
|
||||
val = c - '0';
|
||||
} else if (c >= 'a' && c <= 'f') {
|
||||
val = c - 'a' + 10;
|
||||
} else if (c >= 'A' && c <='F') {
|
||||
val = c - 'A' + 10;
|
||||
c -= 'A' - 'a';
|
||||
} else {
|
||||
int val = hexval(c, HEX_KIND_OID);
|
||||
|
||||
if (val < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (hex_out)
|
||||
hex_out[i] = c;
|
||||
|
||||
Reference in New Issue
Block a user