View Single Post
Old 16th May 2011, 11:18   #51  |  Link
JanWillem32
Registered User
 
JanWillem32's Avatar
 
Join Date: Oct 2010
Location: The Netherlands
Posts: 1,083
If a case-set is used to resolve a single variable, use a compact case-set:
Code:
iconindex = (ext.CompareNoCase(_T(".3g2") == 0)? IDI_VIDEO_ICON
	: (ext.CompareNoCase(_T(".3gp")) == 0)? IDI_VIDEO_ICON
	: (ext.CompareNoCase(_T(".3gp2") == 0)? IDI_VIDEO_ICON
	: IDI_???_ICON;// the last item doesn't have an evaluator, but can often use a comment to clarify why this item is the last option
This also helps the efficiency of the output assembly, as "iconindex" can probably become type-cast as constant (const in C++ code).
If possible, resolve some more math:
Code:
iconindex = (!ext.CompareNoCase(_T(".3g2")) || !ext.CompareNoCase(_T(".3gp")) || !ext.CompareNoCase(_T(".3gp2")))? IDI_VIDEO_ICON
	: IDI_???_ICON;
I just love optimizing boolean logic.
__________________
development folder, containing MPC-HC experimental tester builds, pixel shaders and more: http://www.mediafire.com/?xwsoo403c53hv
JanWillem32 is offline   Reply With Quote