new macro 'nvalue' (to convert an object to a float when we know

object is a number)
This commit is contained in:
Roberto Ierusalimschy
2014-12-19 11:36:32 -02:00
parent 3ae21a352c
commit 2b83711fba
3 changed files with 7 additions and 10 deletions

5
lvm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.229 2014/11/19 15:05:15 roberto Exp roberto $
** $Id: lvm.c,v 2.230 2014/11/21 12:15:00 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -74,8 +74,7 @@ int luaV_tonumber_ (const TValue *obj, lua_Number *n) {
}
else if (cvt2num(obj) && /* string convertible to number? */
luaO_str2num(svalue(obj), &v) == tsvalue(obj)->len + 1) {
/* convert result of 'luaO_str2num' to a float */
*n = (ttisinteger(&v)) ? cast_num(ivalue(&v)) : fltvalue(&v);
*n = nvalue(&v); /* convert result of 'luaO_str2num' to a float */
return 1;
}
else