RE: [GD-Windows] forcing value to bool 'true' or 'false' (performance warning)
Brought to you by:
vexxed72
From: Brian S. <bs...@mi...> - 2002-04-23 01:17:39
|
If you look at the disassembly you'll see it's a little bit more than that, it also has to clamp any integer to the value of "true", which is 1 in the VC++ implementation. Essentially, it does implicitly what your "?" expression does explicitly. --brian > -----Original Message----- > From: Rich [mailto:leg...@xm...]=20 > Sent: Monday, April 22, 2002 6:04 PM > To: gam...@li... > Subject: Re: [GD-Windows] forcing value to bool 'true' or=20 > 'false' (performance warning)=20 >=20 >=20 >=20 > In article <000901c1ea5a$ca4377e0$dc56533e@aurora>, > =3D?iso-8859-1?Q?Ignacio_Casta=3DF1o?=3D <cas...@ya...> = writes: >=20 > > does somebody knows why msvc complains about a performance=20 > warning when > > converting an integer into a bool value? Is there really=20 > any performance > > hit? >=20 > Well, the compiler will generate code to convert an int (4 bytes) to a > bool (usually 1 byte), whether or not it matters for performance is > dubious. >=20 > You can eliminate the warning by doing 'bool p =3D i ? true : false;' > --=20 > Ask me about my upcoming book on Direct3D from Addison-Wesley! > Direct3D Book <http://www.xmission.com/~legalize/book/> > izfree: Open source tools for Windows Installer > <http://izfree.sourceforge.net> >=20 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 >=20 |