introduce LONE_CHAR (optimized strcmp with one-char string)

This commit is contained in:
Denis Vlasenko
2006-12-21 13:23:14 +00:00
parent 6910741067
commit bf66fbc8e2
17 changed files with 49 additions and 35 deletions

View File

@ -136,7 +136,7 @@ static int null(VALUE * v)
if (v->type == integer)
return v->u.i == 0;
else /* string: */
return v->u.s[0] == '\0' || strcmp(v->u.s, "0") == 0;
return v->u.s[0] == '\0' || LONE_CHAR(v->u.s, '0');
}
/* Coerce V to a string value (can't fail). */