Nux

Merge lp:~brandontschaefer/nux/fix-expression-redunancy into lp:nux

Proposed by Brandon Schaefer
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 732
Merged at revision: 733
Proposed branch: lp:~brandontschaefer/nux/fix-expression-redunancy
Merge into: lp:nux
Diff against target: 425 lines (+78/-78)
15 files modified
Nux/HLayout.cpp (+4/-4)
Nux/MainLoopGLib.cpp (+1/-1)
Nux/RangeValue.h (+1/-1)
Nux/RangeValueInteger.h (+1/-1)
Nux/VLayout.cpp (+4/-4)
Nux/WindowCompositor.cpp (+1/-1)
NuxCore/Math/MathUtility.h (+1/-1)
NuxCore/Object.cpp (+2/-2)
NuxCore/ObjectPtr.h (+2/-2)
NuxGraphics/Events.cpp (+15/-15)
NuxGraphics/GpuDevice.cpp (+36/-36)
NuxGraphics/GraphicsDisplayWin.cpp (+1/-1)
NuxGraphics/GraphicsDisplayX11.cpp (+1/-1)
NuxGraphics/IOpenGLCgShader.cpp (+2/-2)
NuxGraphics/IOpenGLGLSLShader.cpp (+6/-6)
To merge this branch: bzr merge lp:~brandontschaefer/nux/fix-expression-redunancy
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+138846@code.launchpad.net

Commit message

Remove (expression) redundancy within the code.

Description of the change

There was a lot '(expression) ? true : false;' in the code, it is redundant...

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote :

One more for the road.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/HLayout.cpp'
2--- Nux/HLayout.cpp 2012-11-17 13:55:47 +0000
3+++ Nux/HLayout.cpp 2012-12-08 01:06:22 +0000
4@@ -364,10 +364,10 @@
5 ret = (*it)->ComputeContentSize();
6 Geometry post_geo = (*it)->GetGeometry();
7
8- bool larger_width = (pre_geo.width < post_geo.width) ? true : false;
9- bool smaller_width = (pre_geo.width > post_geo.width) ? true : false;
10- bool larger_height = (pre_geo.height < post_geo.height) ? true : false;
11- bool smaller_height = (pre_geo.height > post_geo.height) ? true : false;
12+ bool larger_width = pre_geo.width < post_geo.width;
13+ bool smaller_width = pre_geo.width > post_geo.width;
14+ bool larger_height = pre_geo.height < post_geo.height;
15+ bool smaller_height = pre_geo.height > post_geo.height;
16
17 if ((larger_width || smaller_width) && ((*it)->IsLayoutDone() == false))
18 {
19
20=== modified file 'Nux/MainLoopGLib.cpp'
21--- Nux/MainLoopGLib.cpp 2012-11-20 22:13:38 +0000
22+++ Nux/MainLoopGLib.cpp 2012-12-08 01:06:22 +0000
23@@ -49,7 +49,7 @@
24 unsigned int return_code = 1;
25
26 dd->window_thread->_inside_timer_loop = true;
27- repeat = GetTimer().ExecTimerHandler(dd->id)? true : false;
28+ repeat = GetTimer().ExecTimerHandler(dd->id);
29 dd->window_thread->_inside_timer_loop = false;
30
31 if (dd->window_thread->IsEmbeddedWindow())
32
33=== modified file 'Nux/RangeValue.h'
34--- Nux/RangeValue.h 2012-11-05 21:31:06 +0000
35+++ Nux/RangeValue.h 2012-12-08 01:06:22 +0000
36@@ -92,7 +92,7 @@
37
38 bool IsCtrlKeyPressed() const
39 {
40- return (m_CTRL_KEY ? true : false);
41+ return m_CTRL_KEY;
42 }
43
44 // signals
45
46=== modified file 'Nux/RangeValueInteger.h'
47--- Nux/RangeValueInteger.h 2012-11-05 21:31:06 +0000
48+++ Nux/RangeValueInteger.h 2012-12-08 01:06:22 +0000
49@@ -97,7 +97,7 @@
50
51 bool IsCtrlKeyPressed() const
52 {
53- return (m_CTRL_KEY ? true : false);
54+ return m_CTRL_KEY;
55 }
56
57 // signals
58
59=== modified file 'Nux/VLayout.cpp'
60--- Nux/VLayout.cpp 2012-11-17 14:02:43 +0000
61+++ Nux/VLayout.cpp 2012-12-08 01:06:22 +0000
62@@ -371,10 +371,10 @@
63 ret = (*it)->ComputeContentSize();
64 Geometry post_geo = (*it)->GetGeometry();
65
66- bool larger_width = (pre_geo.width < post_geo.width) ? true : false;
67- bool smaller_width = (pre_geo.width > post_geo.width) ? true : false;
68- bool larger_height = (pre_geo.height < post_geo.height) ? true : false;
69- bool smaller_height = (pre_geo.height > post_geo.height) ? true : false;
70+ bool larger_width = pre_geo.width < post_geo.width;
71+ bool smaller_width = pre_geo.width > post_geo.width;
72+ bool larger_height = pre_geo.height < post_geo.height;
73+ bool smaller_height = pre_geo.height > post_geo.height;
74
75 if ((larger_height || smaller_height) && ((*it)->IsLayoutDone() == false))
76 {
77
78=== modified file 'Nux/WindowCompositor.cpp'
79--- Nux/WindowCompositor.cpp 2012-11-27 17:18:13 +0000
80+++ Nux/WindowCompositor.cpp 2012-12-08 01:06:22 +0000
81@@ -2025,7 +2025,7 @@
82 key_focus_area_ = NULL;
83 }
84
85- return key_focus_area_.IsValid() ? true : false;
86+ return key_focus_area_.IsValid();
87 }
88
89 InputArea* WindowCompositor::GetKeyFocusArea()
90
91=== modified file 'NuxCore/Math/MathUtility.h'
92--- NuxCore/Math/MathUtility.h 2012-02-19 03:43:05 +0000
93+++ NuxCore/Math/MathUtility.h 2012-12-08 01:06:22 +0000
94@@ -364,7 +364,7 @@
95 inline bool Hak32_CPULittleEndian()
96 {
97 const int x = 1;
98- return ((unsigned char *) &x) [0] ? true : false;
99+ return ((unsigned char *) &x) [0];
100 }
101
102 // http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
103
104=== modified file 'NuxCore/Object.cpp'
105--- NuxCore/Object.cpp 2012-11-05 21:31:06 +0000
106+++ NuxCore/Object.cpp 2012-12-08 01:06:22 +0000
107@@ -217,10 +217,10 @@
108 {
109 if (_heap_allocated == -1)
110 {
111- _heap_allocated = (IsDynamic () ? 1 : 0);
112+ _heap_allocated = IsDynamic();
113 }
114
115- return (_heap_allocated == 1 ? true : false);
116+ return _heap_allocated;
117 }
118
119 bool Trackable::IsDynamic() const
120
121=== modified file 'NuxCore/ObjectPtr.h'
122--- NuxCore/ObjectPtr.h 2012-11-05 21:31:06 +0000
123+++ NuxCore/ObjectPtr.h 2012-12-08 01:06:22 +0000
124@@ -257,7 +257,7 @@
125 */
126 bool IsValid() const
127 {
128- return (ptr_ != NULL) ? true : false;
129+ return (ptr_ != NULL);
130 }
131
132 bool operator < (T *ptr) const
133@@ -627,7 +627,7 @@
134 */
135 bool IsValid() const
136 {
137- return (ptr_!= NULL) ? true : false;
138+ return (ptr_ != NULL);
139 }
140
141 //! Return true is the hosted pointer is null or has been destroyed.
142
143=== modified file 'NuxGraphics/Events.cpp'
144--- NuxGraphics/Events.cpp 2012-10-18 10:23:45 +0000
145+++ NuxGraphics/Events.cpp 2012-12-08 01:06:22 +0000
146@@ -42,13 +42,13 @@
147 bool GetButtonState(unsigned long button_state, MouseButton button)
148 {
149 if (button == NUX_MOUSE_BUTTON1)
150- return(button_state & NUX_STATE_BUTTON1_DOWN) ? true : false;
151+ return (button_state & NUX_STATE_BUTTON1_DOWN);
152 else if (button == NUX_MOUSE_BUTTON2)
153- return(button_state & NUX_STATE_BUTTON2_DOWN) ? true : false;
154+ return (button_state & NUX_STATE_BUTTON2_DOWN);
155 else if (button == NUX_MOUSE_BUTTON3)
156- return(button_state & NUX_STATE_BUTTON3_DOWN) ? true : false;
157+ return (button_state & NUX_STATE_BUTTON3_DOWN);
158 else if (button == NUX_MOUSE_BUTTON4)
159- return(button_state & NUX_STATE_BUTTON4_DOWN) ? true : false;
160+ return (button_state & NUX_STATE_BUTTON4_DOWN);
161
162 return false;
163 }
164@@ -170,13 +170,13 @@
165 bool Event::GetButtonState(MouseButton button) const
166 {
167 if (button == 1)
168- return(mouse_state & NUX_STATE_BUTTON1_DOWN) ? true : false;
169+ return (mouse_state & NUX_STATE_BUTTON1_DOWN);
170 else if (button == 2)
171- return(mouse_state & NUX_STATE_BUTTON2_DOWN) ? true : false;
172+ return (mouse_state & NUX_STATE_BUTTON2_DOWN);
173 else if (button == 3)
174- return(mouse_state & NUX_STATE_BUTTON3_DOWN) ? true : false;
175+ return (mouse_state & NUX_STATE_BUTTON3_DOWN);
176 else if (button == 4)
177- return(mouse_state & NUX_STATE_BUTTON4_DOWN) ? true : false;
178+ return (mouse_state & NUX_STATE_BUTTON4_DOWN);
179
180 return false;
181 }
182@@ -232,37 +232,37 @@
183
184 bool Event::IsShiftDown() const
185 {
186- return (key_modifiers & NUX_STATE_SHIFT) ? true : false;
187+ return (key_modifiers & NUX_STATE_SHIFT);
188 }
189
190 bool Event::IsControlDown() const
191 {
192- return (key_modifiers & NUX_STATE_CTRL) ? true : false;
193+ return (key_modifiers & NUX_STATE_CTRL);
194 }
195
196 bool Event::IsCapsLockDown() const
197 {
198- return (key_modifiers & NUX_STATE_CAPS_LOCK) ? true : false;
199+ return (key_modifiers & NUX_STATE_CAPS_LOCK);
200 }
201
202 bool Event::IsAltDown() const
203 {
204- return (key_modifiers & NUX_STATE_ALT) ? true : false;
205+ return (key_modifiers & NUX_STATE_ALT);
206 }
207
208 bool Event::IsNumLockDown() const
209 {
210- return (key_modifiers & NUX_STATE_NUMLOCK) ? true : false;
211+ return (key_modifiers & NUX_STATE_NUMLOCK);
212 }
213
214 bool Event::IsScrollLockDown() const
215 {
216- return (key_modifiers & NUX_STATE_SCROLLLOCK) ? true : false;
217+ return (key_modifiers & NUX_STATE_SCROLLLOCK);
218 }
219
220 bool Event::IsSuperKeyDown() const
221 {
222- return (key_modifiers & NUX_STATE_SCROLLLOCK) ? true : false;
223+ return (key_modifiers & NUX_STATE_SCROLLLOCK);
224 }
225
226 }
227
228=== modified file 'NuxGraphics/GpuDevice.cpp'
229--- NuxGraphics/GpuDevice.cpp 2012-11-27 17:18:13 +0000
230+++ NuxGraphics/GpuDevice.cpp 2012-12-08 01:06:22 +0000
231@@ -235,19 +235,19 @@
232 void GpuInfo::Setup()
233 {
234 #ifndef NUX_OPENGLES_20
235- _support_opengl_version_11 = GLEW_VERSION_1_1 ? true : false;
236- _support_opengl_version_12 = GLEW_VERSION_1_2 ? true : false;
237- _support_opengl_version_13 = GLEW_VERSION_1_3 ? true : false;
238- _support_opengl_version_14 = GLEW_VERSION_1_4 ? true : false;
239- _support_opengl_version_15 = GLEW_VERSION_1_5 ? true : false;
240- _support_opengl_version_20 = GLEW_VERSION_2_0 ? true : false;
241- _support_opengl_version_21 = GLEW_VERSION_2_1 ? true : false;
242- _support_opengl_version_30 = GLEW_VERSION_3_0 ? true : false;
243- _support_opengl_version_31 = GLEW_VERSION_3_1 ? true : false;
244- _support_opengl_version_32 = GLEW_VERSION_3_2 ? true : false;
245-// _support_opengl_version_33 = GLEW_VERSION_3_3 ? true : false;
246-// _support_opengl_version_40 = GLEW_VERSION_4_0 ? true : false;
247-// _support_opengl_version_41 = GLEW_VERSION_4_1 ? true : false;
248+ _support_opengl_version_11 = GLEW_VERSION_1_1;
249+ _support_opengl_version_12 = GLEW_VERSION_1_2;
250+ _support_opengl_version_13 = GLEW_VERSION_1_3;
251+ _support_opengl_version_14 = GLEW_VERSION_1_4;
252+ _support_opengl_version_15 = GLEW_VERSION_1_5;
253+ _support_opengl_version_20 = GLEW_VERSION_2_0;
254+ _support_opengl_version_21 = GLEW_VERSION_2_1;
255+ _support_opengl_version_30 = GLEW_VERSION_3_0;
256+ _support_opengl_version_31 = GLEW_VERSION_3_1;
257+ _support_opengl_version_32 = GLEW_VERSION_3_2;
258+// _support_opengl_version_33 = GLEW_VERSION_3_3;
259+// _support_opengl_version_40 = GLEW_VERSION_4_0;
260+// _support_opengl_version_41 = GLEW_VERSION_4_1;
261
262 // See: http://developer.nvidia.com/object/General_FAQ.html
263 // The value of GL_MAX_TEXTURE_UNITS is 4 for GeForce FX and GeForce 6 Series GPUs. Why is that, since those GPUs have 16 texture units?
264@@ -274,31 +274,31 @@
265 #endif
266
267 #if defined(NUX_OS_WINDOWS)
268- _support_ext_swap_control = WGLEW_EXT_swap_control ? true : false;
269+ _support_ext_swap_control = WGLEW_EXT_swap_control;
270 #elif defined(NUX_OS_LINUX) && !defined(NUX_OPENGLES_20)
271- _support_ext_swap_control = GLXEW_SGI_swap_control ? true : false;
272+ _support_ext_swap_control = GLXEW_SGI_swap_control;
273 #endif
274
275 #ifndef NUX_OPENGLES_20
276- _support_arb_vertex_program = GLEW_ARB_vertex_program ? true : false;
277- _support_arb_fragment_program = GLEW_ARB_fragment_program ? true : false;
278- _support_ext_framebuffer_object = GLEW_EXT_framebuffer_object ? true : false;
279- _support_arb_shader_objects = GLEW_ARB_shader_objects ? true : false;
280- _support_arb_vertex_shader = GLEW_ARB_vertex_shader ? true : false;
281- _support_arb_fragment_shader = GLEW_ARB_fragment_shader ? true : false;
282- _support_arb_vertex_buffer_object = GLEW_ARB_vertex_buffer_object ? true : false;
283- _support_arb_texture_non_power_of_two = GLEW_ARB_texture_non_power_of_two ? true : false;
284- _support_ext_draw_range_elements = GLEW_EXT_draw_range_elements ? true : false;
285- _support_ext_stencil_two_side = GLEW_EXT_stencil_two_side ? true : false;
286- _support_ext_texture_rectangle = GLEW_EXT_texture_rectangle ? true : false;
287- _support_arb_texture_rectangle = GLEW_ARB_texture_rectangle ? true : false;
288- _support_nv_texture_rectangle = GLEW_NV_texture_rectangle ? true : false;
289- _support_arb_pixel_buffer_object = GLEW_ARB_pixel_buffer_object ? true : false;
290- _support_ext_blend_equation_separate = GLEW_EXT_blend_equation_separate ? true : false;
291- _support_ext_texture_srgb = GLEW_EXT_texture_sRGB ? true : false;
292- _support_ext_texture_srgb_decode = false; //GLEW_EXT_texture_sRGB_decode ? true : false;
293- _support_ext_framebuffer_srgb = GLEW_EXT_framebuffer_sRGB ? true : false;
294- _support_arb_framebuffer_srgb = GLEW_ARB_framebuffer_sRGB ? true : false;
295+ _support_arb_vertex_program = GLEW_ARB_vertex_program;
296+ _support_arb_fragment_program = GLEW_ARB_fragment_program;
297+ _support_ext_framebuffer_object = GLEW_EXT_framebuffer_object;
298+ _support_arb_shader_objects = GLEW_ARB_shader_objects;
299+ _support_arb_vertex_shader = GLEW_ARB_vertex_shader;
300+ _support_arb_fragment_shader = GLEW_ARB_fragment_shader;
301+ _support_arb_vertex_buffer_object = GLEW_ARB_vertex_buffer_object;
302+ _support_arb_texture_non_power_of_two = GLEW_ARB_texture_non_power_of_two;
303+ _support_ext_draw_range_elements = GLEW_EXT_draw_range_elements;
304+ _support_ext_stencil_two_side = GLEW_EXT_stencil_two_side;
305+ _support_ext_texture_rectangle = GLEW_EXT_texture_rectangle;
306+ _support_arb_texture_rectangle = GLEW_ARB_texture_rectangle;
307+ _support_nv_texture_rectangle = GLEW_NV_texture_rectangle;
308+ _support_arb_pixel_buffer_object = GLEW_ARB_pixel_buffer_object;
309+ _support_ext_blend_equation_separate = GLEW_EXT_blend_equation_separate;
310+ _support_ext_texture_srgb = GLEW_EXT_texture_sRGB;
311+ _support_ext_texture_srgb_decode = false; //GLEW_EXT_texture_sRGB_decode;
312+ _support_ext_framebuffer_srgb = GLEW_EXT_framebuffer_sRGB;
313+ _support_arb_framebuffer_srgb = GLEW_ARB_framebuffer_sRGB;
314 #else
315 _support_arb_vertex_program = false;
316 _support_arb_fragment_program = false;
317@@ -679,9 +679,9 @@
318 gpu_render_states_ = new GpuRenderStates(gpu_brand_, gpu_info_);
319
320 #if defined(NUX_OS_WINDOWS)
321- OGL_EXT_SWAP_CONTROL = WGLEW_EXT_swap_control ? true : false;
322+ OGL_EXT_SWAP_CONTROL = WGLEW_EXT_swap_control;
323 #elif defined(NUX_OS_LINUX) && !defined(NUX_OPENGLES_20)
324- OGL_EXT_SWAP_CONTROL = GLXEW_SGI_swap_control ? true : false;
325+ OGL_EXT_SWAP_CONTROL = GLXEW_SGI_swap_control;
326 #endif
327
328 InitTextureFormats();
329
330=== modified file 'NuxGraphics/GraphicsDisplayWin.cpp'
331--- NuxGraphics/GraphicsDisplayWin.cpp 2012-11-05 21:31:06 +0000
332+++ NuxGraphics/GraphicsDisplayWin.cpp 2012-12-08 01:06:22 +0000
333@@ -2332,7 +2332,7 @@
334
335 bool GraphicsDisplay::IsWindowVisible()
336 {
337- return(::IsWindowVisible(wnd_handle_) ? true : false);
338+ return ::IsWindowVisible(wnd_handle_);
339 }
340 //---------------------------------------------------------------------------------------------------------
341 void GraphicsDisplay::EnterMaximizeWindow()
342
343=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
344--- NuxGraphics/GraphicsDisplayX11.cpp 2012-12-04 00:09:49 +0000
345+++ NuxGraphics/GraphicsDisplayX11.cpp 2012-12-08 01:06:22 +0000
346@@ -1441,7 +1441,7 @@
347
348 bool GraphicsDisplay::HasXPendingEvent() const
349 {
350- return XPending(m_X11Display) ? true : false;
351+ return XPending(m_X11Display);
352 }
353
354 void GraphicsDisplay::RecalcXYPosition(int x_root, int y_root, int &x_recalc, int &y_recalc)
355
356=== modified file 'NuxGraphics/IOpenGLCgShader.cpp'
357--- NuxGraphics/IOpenGLCgShader.cpp 2011-10-19 20:32:38 +0000
358+++ NuxGraphics/IOpenGLCgShader.cpp 2012-12-08 01:06:22 +0000
359@@ -117,7 +117,7 @@
360
361 bool ICgVertexShader::IsValid()
362 {
363- return(_ready ? true : false);
364+ return _ready;
365 }
366
367 ICgPixelShader::ICgPixelShader(NString ShaderName)
368@@ -175,7 +175,7 @@
369
370 bool ICgPixelShader::IsValid()
371 {
372- return(_ready ? true : false);
373+ return _ready;
374 }
375
376 void cgErrorCallback(void)
377
378=== modified file 'NuxGraphics/IOpenGLGLSLShader.cpp'
379--- NuxGraphics/IOpenGLGLSLShader.cpp 2012-11-17 14:37:27 +0000
380+++ NuxGraphics/IOpenGLGLSLShader.cpp 2012-12-08 01:06:22 +0000
381@@ -266,12 +266,12 @@
382 delete[] InfoLogBuffer;
383 }
384
385- return(m_CompiledAndReady ? true : false);
386+ return m_CompiledAndReady;
387 }
388
389 bool IOpenGLVertexShader::IsValid()
390 {
391- return(m_CompiledAndReady ? true : false);
392+ return m_CompiledAndReady;
393 }
394
395 IOpenGLPixelShader::IOpenGLPixelShader(std::string ShaderName)
396@@ -347,12 +347,12 @@
397 delete[] InfoLogBuffer;
398 }
399
400- return(m_CompiledAndReady ? true : false);
401+ return m_CompiledAndReady;
402 }
403
404 bool IOpenGLPixelShader::IsValid()
405 {
406- return(m_CompiledAndReady ? true : false);
407+ return m_CompiledAndReady;
408 }
409
410 #if 0
411@@ -427,12 +427,12 @@
412 delete InfoLogBuffer;
413 }
414
415- return(m_CompiledAndReady ? true : false);
416+ return m_CompiledAndReady;
417 }
418
419 bool IOpenGLGeometryShader::IsValid()
420 {
421- return(m_CompiledAndReady ? true : false);
422+ return m_CompiledAndReady;
423 }
424
425 void IOpenGLGeometryShader::SetInputPrimitiveType(GLenum type)

Subscribers

People subscribed via source and target branches