Nux

Merge lp:~mc-return/nux/nux.merge-reduce-the-scope-of-various-variables into lp:nux

Proposed by MC Return
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 714
Merged at revision: 730
Proposed branch: lp:~mc-return/nux/nux.merge-reduce-the-scope-of-various-variables
Merge into: lp:nux
Diff against target: 139 lines (+23/-34)
5 files modified
Nux/HLayout.cpp (+4/-8)
Nux/VLayout.cpp (+4/-8)
NuxCore/LoggingWriter.cpp (+3/-2)
NuxGraphics/IOpenGLBaseTexture.cpp (+7/-9)
NuxGraphics/IOpenGLGLSLShader.cpp (+5/-7)
To merge this branch: bzr merge lp:~mc-return/nux/nux.merge-reduce-the-scope-of-various-variables
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+134787@code.launchpad.net

Commit message

Reduced the scope of various variables.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Looks good to me.

review: Approve
Revision history for this message
Tim Penhey (thumper) wrote :

On 06/12/12 15:11, <email address hidden> wrote:
> The proposal to merge lp:~mc-return/nux/nux.merge-reduce-the-scope-of-various-variables into lp:nux has been updated.
>
> Status: Approved => Merged
>
> For more details, see:
> https://code.launchpad.net/~mc-return/nux/nux.merge-reduce-the-scope-of-various-variables/+merge/134787
>

I don't suppose you are interested in amending those merges to change

bool foo = (a < b) ? true : false;

to just bee

bool foo = a < b;

?

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Geez...I didn't notice how bad that was... Ill push a branch with those changes tomorrow.

Revision history for this message
MC Return (mc-return) wrote :

> I don't suppose you are interested in amending those merges to change
>
> bool foo = (a < b) ? true : false;
>
> to just bee
>
> bool foo = a < b;

I did not make such changes.
I just changed the local bools, which where initialized with false, then not used, and after the if statement reassigned a new value, without the old one having been used.
So I removed the initial, unused initialization with false and only declared and initialized them with the correct value later...

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

@MC

Yes, what Tim wants is to change:
bool larger_width = (pre_geo.width < post_geo.width) ? true : false;

to:
bool larger_width = pre_geo.width < post_geo.width;

... does that make sense how bad that looks?

Revision history for this message
MC Return (mc-return) wrote :

@Brandon:

Ah - yes, makes sense.
I am not sure if it looks better, but it produces the same results - so, if that version is faster we should change it, otherwise probably not...

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-10-10 22:46:50 +0000
3+++ Nux/HLayout.cpp 2012-11-17 22:04:21 +0000
4@@ -356,10 +356,6 @@
5 if (!(*it)->IsVisible())
6 continue;
7
8- bool smaller_height = false;
9- bool larger_height = false;
10- bool larger_width = false;
11- bool smaller_width = false;
12 int ret = 0;
13
14 if (((*it)->IsLayout() || (*it)->IsView()) /*&& ((*it)->IsLayoutDone() == false)*/ /*&& ((*it)->GetScaleFactor() != 0)*/)
15@@ -368,10 +364,10 @@
16 ret = (*it)->ComputeContentSize();
17 Geometry post_geo = (*it)->GetGeometry();
18
19- larger_width = (pre_geo.width < post_geo.width) ? true : false;
20- smaller_width = (pre_geo.width > post_geo.width) ? true : false;
21- larger_height = (pre_geo.height < post_geo.height) ? true : false;
22- smaller_height = (pre_geo.height > post_geo.height) ? true : false;
23+ bool larger_width = (pre_geo.width < post_geo.width) ? true : false;
24+ bool smaller_width = (pre_geo.width > post_geo.width) ? true : false;
25+ bool larger_height = (pre_geo.height < post_geo.height) ? true : false;
26+ bool smaller_height = (pre_geo.height > post_geo.height) ? true : false;
27
28 if ((larger_width || smaller_width) && ((*it)->IsLayoutDone() == false))
29 {
30
31=== modified file 'Nux/VLayout.cpp'
32--- Nux/VLayout.cpp 2012-10-10 22:46:50 +0000
33+++ Nux/VLayout.cpp 2012-11-17 22:04:21 +0000
34@@ -363,10 +363,6 @@
35 if (!(*it)->IsVisible())
36 continue;
37
38- bool larger_height = false;
39- bool smaller_height = false;
40- bool smaller_width = false;
41- bool larger_width = false;
42 int ret = 0;
43
44 if (((*it)->IsLayout() || (*it)->IsView()) /*&& ((*it)->IsLayoutDone() == false)*/ /*&& ((*it)->GetScaleFactor() != 0)*/)
45@@ -375,10 +371,10 @@
46 ret = (*it)->ComputeContentSize();
47 Geometry post_geo = (*it)->GetGeometry();
48
49- larger_width = (pre_geo.width < post_geo.width) ? true : false;
50- smaller_width = (pre_geo.width > post_geo.width) ? true : false;
51- larger_height = (pre_geo.height < post_geo.height) ? true : false;
52- smaller_height = (pre_geo.height > post_geo.height) ? true : false;
53+ bool larger_width = (pre_geo.width < post_geo.width) ? true : false;
54+ bool smaller_width = (pre_geo.width > post_geo.width) ? true : false;
55+ bool larger_height = (pre_geo.height < post_geo.height) ? true : false;
56+ bool smaller_height = (pre_geo.height > post_geo.height) ? true : false;
57
58 if ((larger_height || smaller_height) && ((*it)->IsLayoutDone() == false))
59 {
60
61=== modified file 'NuxCore/LoggingWriter.cpp'
62--- NuxCore/LoggingWriter.cpp 2011-08-22 01:12:28 +0000
63+++ NuxCore/LoggingWriter.cpp 2012-11-17 22:04:21 +0000
64@@ -85,12 +85,13 @@
65 tm local_time;
66
67 #if defined(NUX_OS_WINDOWS)
68- static const char* invalid_time_stamp = "invalid_time_stamp";
69-
70 if (localtime_s(&local_time, &timestamp) == 0)
71 std::strftime(buffer, buf_size, format, &local_time);
72 else
73+ {
74+ static const char* invalid_time_stamp = "invalid_time_stamp";
75 memcpy_s(buffer, sizeof(buffer), invalid_time_stamp, strnlen(invalid_time_stamp, 30));
76+ }
77 #else
78 std::strftime(buffer, buf_size, format, ::localtime_r(&timestamp, &local_time));
79 #endif
80
81=== modified file 'NuxGraphics/IOpenGLBaseTexture.cpp'
82--- NuxGraphics/IOpenGLBaseTexture.cpp 2012-09-26 06:44:12 +0000
83+++ NuxGraphics/IOpenGLBaseTexture.cpp 2012-11-17 22:04:21 +0000
84@@ -324,8 +324,6 @@
85 GLint unpack_alignment = GPixelFormats[pTexture->_PixelFormat].RowMemoryAlignment;
86 unsigned int halfUnpack = Log2(unpack_alignment);
87
88- unsigned int BytePerPixel = 0;
89-
90 pDesc->PixelFormat = pTexture->_PixelFormat;
91
92 if ( /*pTexture->_Format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||*/
93@@ -388,13 +386,13 @@
94 }
95 else
96 {
97- pDesc->Width = Max<unsigned int> (1, pTexture->_Width >> Level);
98- pDesc->Height = Max<unsigned int> (1, pTexture->_Height >> Level);
99- pDesc->WidthInBlocks = pDesc->Width;
100- pDesc->HeightInBlocks = pDesc->Height;
101- BytePerPixel = GPixelFormats[pTexture->_PixelFormat].BlockBytes;
102- pDesc->BitsPerPixel = BytePerPixel * 8;
103- pDesc->BytesPerBlock = BytePerPixel; // a block is a 1x1 pixel ie. 1 pixel.
104+ pDesc->Width = Max<unsigned int> (1, pTexture->_Width >> Level);
105+ pDesc->Height = Max<unsigned int> (1, pTexture->_Height >> Level);
106+ pDesc->WidthInBlocks = pDesc->Width;
107+ pDesc->HeightInBlocks = pDesc->Height;
108+ unsigned int BytePerPixel = GPixelFormats[pTexture->_PixelFormat].BlockBytes;
109+ pDesc->BitsPerPixel = BytePerPixel * 8;
110+ pDesc->BytesPerBlock = BytePerPixel; // a block is a 1x1 pixel ie. 1 pixel.
111 pDesc->RowPitch = (((pDesc->Width * BytePerPixel + (unpack_alignment - 1)) >> (halfUnpack)) << (halfUnpack));
112 pDesc->SlicePitch = (((pDesc->Width * BytePerPixel + (unpack_alignment - 1)) >> (halfUnpack)) << (halfUnpack)) * pDesc->Height;
113 }
114
115=== modified file 'NuxGraphics/IOpenGLGLSLShader.cpp'
116--- NuxGraphics/IOpenGLGLSLShader.cpp 2012-11-04 10:45:15 +0000
117+++ NuxGraphics/IOpenGLGLSLShader.cpp 2012-11-17 22:04:21 +0000
118@@ -45,16 +45,14 @@
119
120 bool ExtractShaderString3(const std::string &ShaderToken, const std::string &ShaderSource, std::string &RetSource, std::string ShaderPreprocessorDefines)
121 {
122- size_t lineStart = 0;
123- size_t lineCount = 1;
124- bool startTokenFound = false;
125- size_t shaderStringStart = 0;
126- size_t shaderStartLine = 1;
127-
128-
129 //Loop for all characters in the string
130 if (ShaderToken != "")
131 {
132+ size_t lineStart = 0;
133+ size_t lineCount = 1;
134+ bool startTokenFound = false;
135+ size_t shaderStringStart = 0;
136+ size_t shaderStartLine = 1;
137 size_t i;
138
139 for (i = 0; i < ShaderSource.length(); i++)

Subscribers

People subscribed via source and target branches