Nux

Merge lp:~brandontschaefer/nux/reduce-redunancy into lp:nux

Proposed by Brandon Schaefer
Status: Merged
Approved by: Martin Mrazik
Approved revision: 731
Merged at revision: 732
Proposed branch: lp:~brandontschaefer/nux/reduce-redunancy
Merge into: lp:nux
Diff against target: 426 lines (+78/-80)
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/-4)
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/reduce-redunancy
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Stephen M. Webb (community) Approve
Review via email: mp+138542@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 :

I support this kind of clarification (although I hate unbraced clauses, I've been burned too often).

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Mrazik (mrazik) wrote :

Jenkins misconfiguration -> reapproving.

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-06 19:24:53 +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-06 19:24:53 +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-06 19:24:53 +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-06 19:24:53 +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-06 19:24:53 +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-06 19:24:53 +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-06 19:24:53 +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-06 19:24:53 +0000
107@@ -216,11 +216,9 @@
108 bool Trackable::IsHeapAllocated()
109 {
110 if (_heap_allocated == -1)
111- {
112- _heap_allocated = (IsDynamic () ? 1 : 0);
113- }
114+ _heap_allocated = IsDynamic();
115
116- return (_heap_allocated == 1 ? true : false);
117+ return _heap_allocated;
118 }
119
120 bool Trackable::IsDynamic() const
121
122=== modified file 'NuxCore/ObjectPtr.h'
123--- NuxCore/ObjectPtr.h 2012-11-05 21:31:06 +0000
124+++ NuxCore/ObjectPtr.h 2012-12-06 19:24:53 +0000
125@@ -257,7 +257,7 @@
126 */
127 bool IsValid() const
128 {
129- return (ptr_ != NULL) ? true : false;
130+ return (ptr_ != NULL);
131 }
132
133 bool operator < (T *ptr) const
134@@ -627,7 +627,7 @@
135 */
136 bool IsValid() const
137 {
138- return (ptr_!= NULL) ? true : false;
139+ return (ptr_ != NULL);
140 }
141
142 //! Return true is the hosted pointer is null or has been destroyed.
143
144=== modified file 'NuxGraphics/Events.cpp'
145--- NuxGraphics/Events.cpp 2012-10-18 10:23:45 +0000
146+++ NuxGraphics/Events.cpp 2012-12-06 19:24:53 +0000
147@@ -42,13 +42,13 @@
148 bool GetButtonState(unsigned long button_state, MouseButton button)
149 {
150 if (button == NUX_MOUSE_BUTTON1)
151- return(button_state & NUX_STATE_BUTTON1_DOWN) ? true : false;
152+ return (button_state & NUX_STATE_BUTTON1_DOWN);
153 else if (button == NUX_MOUSE_BUTTON2)
154- return(button_state & NUX_STATE_BUTTON2_DOWN) ? true : false;
155+ return (button_state & NUX_STATE_BUTTON2_DOWN);
156 else if (button == NUX_MOUSE_BUTTON3)
157- return(button_state & NUX_STATE_BUTTON3_DOWN) ? true : false;
158+ return (button_state & NUX_STATE_BUTTON3_DOWN);
159 else if (button == NUX_MOUSE_BUTTON4)
160- return(button_state & NUX_STATE_BUTTON4_DOWN) ? true : false;
161+ return (button_state & NUX_STATE_BUTTON4_DOWN);
162
163 return false;
164 }
165@@ -170,13 +170,13 @@
166 bool Event::GetButtonState(MouseButton button) const
167 {
168 if (button == 1)
169- return(mouse_state & NUX_STATE_BUTTON1_DOWN) ? true : false;
170+ return (mouse_state & NUX_STATE_BUTTON1_DOWN);
171 else if (button == 2)
172- return(mouse_state & NUX_STATE_BUTTON2_DOWN) ? true : false;
173+ return (mouse_state & NUX_STATE_BUTTON2_DOWN);
174 else if (button == 3)
175- return(mouse_state & NUX_STATE_BUTTON3_DOWN) ? true : false;
176+ return (mouse_state & NUX_STATE_BUTTON3_DOWN);
177 else if (button == 4)
178- return(mouse_state & NUX_STATE_BUTTON4_DOWN) ? true : false;
179+ return (mouse_state & NUX_STATE_BUTTON4_DOWN);
180
181 return false;
182 }
183@@ -232,37 +232,37 @@
184
185 bool Event::IsShiftDown() const
186 {
187- return (key_modifiers & NUX_STATE_SHIFT) ? true : false;
188+ return (key_modifiers & NUX_STATE_SHIFT);
189 }
190
191 bool Event::IsControlDown() const
192 {
193- return (key_modifiers & NUX_STATE_CTRL) ? true : false;
194+ return (key_modifiers & NUX_STATE_CTRL);
195 }
196
197 bool Event::IsCapsLockDown() const
198 {
199- return (key_modifiers & NUX_STATE_CAPS_LOCK) ? true : false;
200+ return (key_modifiers & NUX_STATE_CAPS_LOCK);
201 }
202
203 bool Event::IsAltDown() const
204 {
205- return (key_modifiers & NUX_STATE_ALT) ? true : false;
206+ return (key_modifiers & NUX_STATE_ALT);
207 }
208
209 bool Event::IsNumLockDown() const
210 {
211- return (key_modifiers & NUX_STATE_NUMLOCK) ? true : false;
212+ return (key_modifiers & NUX_STATE_NUMLOCK);
213 }
214
215 bool Event::IsScrollLockDown() const
216 {
217- return (key_modifiers & NUX_STATE_SCROLLLOCK) ? true : false;
218+ return (key_modifiers & NUX_STATE_SCROLLLOCK);
219 }
220
221 bool Event::IsSuperKeyDown() const
222 {
223- return (key_modifiers & NUX_STATE_SCROLLLOCK) ? true : false;
224+ return (key_modifiers & NUX_STATE_SCROLLLOCK);
225 }
226
227 }
228
229=== modified file 'NuxGraphics/GpuDevice.cpp'
230--- NuxGraphics/GpuDevice.cpp 2012-11-27 17:18:13 +0000
231+++ NuxGraphics/GpuDevice.cpp 2012-12-06 19:24:53 +0000
232@@ -235,19 +235,19 @@
233 void GpuInfo::Setup()
234 {
235 #ifndef NUX_OPENGLES_20
236- _support_opengl_version_11 = GLEW_VERSION_1_1 ? true : false;
237- _support_opengl_version_12 = GLEW_VERSION_1_2 ? true : false;
238- _support_opengl_version_13 = GLEW_VERSION_1_3 ? true : false;
239- _support_opengl_version_14 = GLEW_VERSION_1_4 ? true : false;
240- _support_opengl_version_15 = GLEW_VERSION_1_5 ? true : false;
241- _support_opengl_version_20 = GLEW_VERSION_2_0 ? true : false;
242- _support_opengl_version_21 = GLEW_VERSION_2_1 ? true : false;
243- _support_opengl_version_30 = GLEW_VERSION_3_0 ? true : false;
244- _support_opengl_version_31 = GLEW_VERSION_3_1 ? true : false;
245- _support_opengl_version_32 = GLEW_VERSION_3_2 ? true : false;
246-// _support_opengl_version_33 = GLEW_VERSION_3_3 ? true : false;
247-// _support_opengl_version_40 = GLEW_VERSION_4_0 ? true : false;
248-// _support_opengl_version_41 = GLEW_VERSION_4_1 ? true : false;
249+ _support_opengl_version_11 = GLEW_VERSION_1_1;
250+ _support_opengl_version_12 = GLEW_VERSION_1_2;
251+ _support_opengl_version_13 = GLEW_VERSION_1_3;
252+ _support_opengl_version_14 = GLEW_VERSION_1_4;
253+ _support_opengl_version_15 = GLEW_VERSION_1_5;
254+ _support_opengl_version_20 = GLEW_VERSION_2_0;
255+ _support_opengl_version_21 = GLEW_VERSION_2_1;
256+ _support_opengl_version_30 = GLEW_VERSION_3_0;
257+ _support_opengl_version_31 = GLEW_VERSION_3_1;
258+ _support_opengl_version_32 = GLEW_VERSION_3_2;
259+// _support_opengl_version_33 = GLEW_VERSION_3_3;
260+// _support_opengl_version_40 = GLEW_VERSION_4_0;
261+// _support_opengl_version_41 = GLEW_VERSION_4_1;
262
263 // See: http://developer.nvidia.com/object/General_FAQ.html
264 // 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?
265@@ -274,31 +274,31 @@
266 #endif
267
268 #if defined(NUX_OS_WINDOWS)
269- _support_ext_swap_control = WGLEW_EXT_swap_control ? true : false;
270+ _support_ext_swap_control = WGLEW_EXT_swap_control;
271 #elif defined(NUX_OS_LINUX) && !defined(NUX_OPENGLES_20)
272- _support_ext_swap_control = GLXEW_SGI_swap_control ? true : false;
273+ _support_ext_swap_control = GLXEW_SGI_swap_control;
274 #endif
275
276 #ifndef NUX_OPENGLES_20
277- _support_arb_vertex_program = GLEW_ARB_vertex_program ? true : false;
278- _support_arb_fragment_program = GLEW_ARB_fragment_program ? true : false;
279- _support_ext_framebuffer_object = GLEW_EXT_framebuffer_object ? true : false;
280- _support_arb_shader_objects = GLEW_ARB_shader_objects ? true : false;
281- _support_arb_vertex_shader = GLEW_ARB_vertex_shader ? true : false;
282- _support_arb_fragment_shader = GLEW_ARB_fragment_shader ? true : false;
283- _support_arb_vertex_buffer_object = GLEW_ARB_vertex_buffer_object ? true : false;
284- _support_arb_texture_non_power_of_two = GLEW_ARB_texture_non_power_of_two ? true : false;
285- _support_ext_draw_range_elements = GLEW_EXT_draw_range_elements ? true : false;
286- _support_ext_stencil_two_side = GLEW_EXT_stencil_two_side ? true : false;
287- _support_ext_texture_rectangle = GLEW_EXT_texture_rectangle ? true : false;
288- _support_arb_texture_rectangle = GLEW_ARB_texture_rectangle ? true : false;
289- _support_nv_texture_rectangle = GLEW_NV_texture_rectangle ? true : false;
290- _support_arb_pixel_buffer_object = GLEW_ARB_pixel_buffer_object ? true : false;
291- _support_ext_blend_equation_separate = GLEW_EXT_blend_equation_separate ? true : false;
292- _support_ext_texture_srgb = GLEW_EXT_texture_sRGB ? true : false;
293- _support_ext_texture_srgb_decode = false; //GLEW_EXT_texture_sRGB_decode ? true : false;
294- _support_ext_framebuffer_srgb = GLEW_EXT_framebuffer_sRGB ? true : false;
295- _support_arb_framebuffer_srgb = GLEW_ARB_framebuffer_sRGB ? true : false;
296+ _support_arb_vertex_program = GLEW_ARB_vertex_program;
297+ _support_arb_fragment_program = GLEW_ARB_fragment_program;
298+ _support_ext_framebuffer_object = GLEW_EXT_framebuffer_object;
299+ _support_arb_shader_objects = GLEW_ARB_shader_objects;
300+ _support_arb_vertex_shader = GLEW_ARB_vertex_shader;
301+ _support_arb_fragment_shader = GLEW_ARB_fragment_shader;
302+ _support_arb_vertex_buffer_object = GLEW_ARB_vertex_buffer_object;
303+ _support_arb_texture_non_power_of_two = GLEW_ARB_texture_non_power_of_two;
304+ _support_ext_draw_range_elements = GLEW_EXT_draw_range_elements;
305+ _support_ext_stencil_two_side = GLEW_EXT_stencil_two_side;
306+ _support_ext_texture_rectangle = GLEW_EXT_texture_rectangle;
307+ _support_arb_texture_rectangle = GLEW_ARB_texture_rectangle;
308+ _support_nv_texture_rectangle = GLEW_NV_texture_rectangle;
309+ _support_arb_pixel_buffer_object = GLEW_ARB_pixel_buffer_object;
310+ _support_ext_blend_equation_separate = GLEW_EXT_blend_equation_separate;
311+ _support_ext_texture_srgb = GLEW_EXT_texture_sRGB;
312+ _support_ext_texture_srgb_decode = false; //GLEW_EXT_texture_sRGB_decode;
313+ _support_ext_framebuffer_srgb = GLEW_EXT_framebuffer_sRGB;
314+ _support_arb_framebuffer_srgb = GLEW_ARB_framebuffer_sRGB;
315 #else
316 _support_arb_vertex_program = false;
317 _support_arb_fragment_program = false;
318@@ -679,9 +679,9 @@
319 gpu_render_states_ = new GpuRenderStates(gpu_brand_, gpu_info_);
320
321 #if defined(NUX_OS_WINDOWS)
322- OGL_EXT_SWAP_CONTROL = WGLEW_EXT_swap_control ? true : false;
323+ OGL_EXT_SWAP_CONTROL = WGLEW_EXT_swap_control;
324 #elif defined(NUX_OS_LINUX) && !defined(NUX_OPENGLES_20)
325- OGL_EXT_SWAP_CONTROL = GLXEW_SGI_swap_control ? true : false;
326+ OGL_EXT_SWAP_CONTROL = GLXEW_SGI_swap_control;
327 #endif
328
329 InitTextureFormats();
330
331=== modified file 'NuxGraphics/GraphicsDisplayWin.cpp'
332--- NuxGraphics/GraphicsDisplayWin.cpp 2012-11-05 21:31:06 +0000
333+++ NuxGraphics/GraphicsDisplayWin.cpp 2012-12-06 19:24:53 +0000
334@@ -2332,7 +2332,7 @@
335
336 bool GraphicsDisplay::IsWindowVisible()
337 {
338- return(::IsWindowVisible(wnd_handle_) ? true : false);
339+ return ::IsWindowVisible(wnd_handle_);
340 }
341 //---------------------------------------------------------------------------------------------------------
342 void GraphicsDisplay::EnterMaximizeWindow()
343
344=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
345--- NuxGraphics/GraphicsDisplayX11.cpp 2012-12-04 00:09:49 +0000
346+++ NuxGraphics/GraphicsDisplayX11.cpp 2012-12-06 19:24:53 +0000
347@@ -1441,7 +1441,7 @@
348
349 bool GraphicsDisplay::HasXPendingEvent() const
350 {
351- return XPending(m_X11Display) ? true : false;
352+ return XPending(m_X11Display);
353 }
354
355 void GraphicsDisplay::RecalcXYPosition(int x_root, int y_root, int &x_recalc, int &y_recalc)
356
357=== modified file 'NuxGraphics/IOpenGLCgShader.cpp'
358--- NuxGraphics/IOpenGLCgShader.cpp 2011-10-19 20:32:38 +0000
359+++ NuxGraphics/IOpenGLCgShader.cpp 2012-12-06 19:24:53 +0000
360@@ -117,7 +117,7 @@
361
362 bool ICgVertexShader::IsValid()
363 {
364- return(_ready ? true : false);
365+ return _ready;
366 }
367
368 ICgPixelShader::ICgPixelShader(NString ShaderName)
369@@ -175,7 +175,7 @@
370
371 bool ICgPixelShader::IsValid()
372 {
373- return(_ready ? true : false);
374+ return _ready;
375 }
376
377 void cgErrorCallback(void)
378
379=== modified file 'NuxGraphics/IOpenGLGLSLShader.cpp'
380--- NuxGraphics/IOpenGLGLSLShader.cpp 2012-11-17 14:37:27 +0000
381+++ NuxGraphics/IOpenGLGLSLShader.cpp 2012-12-06 19:24:53 +0000
382@@ -266,12 +266,12 @@
383 delete[] InfoLogBuffer;
384 }
385
386- return(m_CompiledAndReady ? true : false);
387+ return m_CompiledAndReady;
388 }
389
390 bool IOpenGLVertexShader::IsValid()
391 {
392- return(m_CompiledAndReady ? true : false);
393+ return m_CompiledAndReady;
394 }
395
396 IOpenGLPixelShader::IOpenGLPixelShader(std::string ShaderName)
397@@ -347,12 +347,12 @@
398 delete[] InfoLogBuffer;
399 }
400
401- return(m_CompiledAndReady ? true : false);
402+ return m_CompiledAndReady;
403 }
404
405 bool IOpenGLPixelShader::IsValid()
406 {
407- return(m_CompiledAndReady ? true : false);
408+ return m_CompiledAndReady;
409 }
410
411 #if 0
412@@ -427,12 +427,12 @@
413 delete InfoLogBuffer;
414 }
415
416- return(m_CompiledAndReady ? true : false);
417+ return m_CompiledAndReady;
418 }
419
420 bool IOpenGLGeometryShader::IsValid()
421 {
422- return(m_CompiledAndReady ? true : false);
423+ return m_CompiledAndReady;
424 }
425
426 void IOpenGLGeometryShader::SetInputPrimitiveType(GLenum type)

Subscribers

People subscribed via source and target branches