Avoid useless double attempt at converting string to integer

Fixup dmap_add_field() and one of its callers to avoid making two useless
attempts at converting a string to an integer in some cases.
This commit is contained in:
Julien BLACHE 2010-01-20 18:34:36 +01:00
parent ba251b16ae
commit 87abc3f432
1 changed files with 3 additions and 5 deletions

View File

@ -524,11 +524,9 @@ dmap_add_field(struct evbuffer *evbuf, struct dmap_field_map *dfm, char *strval,
int val; int val;
int ret; int ret;
val = 0; val = intval;
if (intval != 0) if ((dfm->type != DMAP_TYPE_STRING) && (val == 0) && strval)
val = intval;
else if (strval)
{ {
ret = safe_atoi(strval, &val); ret = safe_atoi(strval, &val);
if (ret < 0) if (ret < 0)
@ -1300,7 +1298,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
} }
} }
if (*strval) if (*strval && (dfm->type != DMAP_TYPE_STRING))
{ {
ret = safe_atoi(*strval, &val); ret = safe_atoi(*strval, &val);
if (ret < 0) if (ret < 0)