Add cast to unsigned to improve div by 2 in find_internal_func()

This commit is contained in:
Felipe Oliveira Carvalho 2014-04-22 03:06:29 -03:00 committed by Thiago de Arruda
parent db23cb05d1
commit 3f38c384ef

View File

@ -7155,15 +7155,13 @@ find_internal_func (
{
int first = 0;
int last = (int)(sizeof(functions) / sizeof(struct fst)) - 1;
int cmp;
int x;
/*
* Find the function name in the table. Binary search.
*/
while (first <= last) {
x = first + (last - first) / 2;
cmp = STRCMP(name, functions[x].f_name);
int x = first + ((unsigned)(last - first)) / 2;
int cmp = STRCMP(name, functions[x].f_name);
if (cmp < 0)
last = x - 1;
else if (cmp > 0)