mgcp_client: tweak extract_codec_name() implementation

Instead of calling strlen() for every loop iteration, just use strchr()
to find the position of '/'.

Change-Id: Ifc7302b6c5f9288a622e33c3e8b5fe0e7037dbdc
This commit is contained in:
Neels Hofmeyr 2023-06-30 05:09:53 +02:00
parent e9989b9e76
commit c364f4ab5a
1 changed files with 4 additions and 5 deletions

View File

@ -69,17 +69,16 @@ const struct value_string osmo_mgcpc_codec_names[] = {
static char *extract_codec_name(const char *str)
{
static char buf[64];
unsigned int i;
char *pos;
if (!str)
return NULL;
osmo_strlcpy(buf, str, sizeof(buf));
for (i = 0; i < strlen(buf); i++) {
if (buf[i] == '/')
buf[i] = '\0';
}
pos = strchr(buf, '/');
if (pos)
*pos = '\0';
return buf;
}