~ps-jenkins/compiz/latestsnapshot-10.9.9daily13.06.1913.04-0ubuntu1

« back to all changes in this revision

Viewing changes to plugins/opengl/src/matrix.cpp

Minor Performance Optimizations:

* Return ASAP./Prevent executing any unnecessary operations if we return.
* Used De Morgan's laws to merge and simplify if statements.

Other Changes:

* C++ Style: Declared iterator variables inside the for loops they are used in.
* No logic changes have been made.

Approved by Daniel van Vugt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
         const float *a,
89
89
         const float *b)
90
90
{
91
 
    int i;
92
 
 
93
 
    for (i = 0; i < 4; i++)
 
91
    for (int i = 0; i < 4; i++)
94
92
    {
95
93
        const float ai0 = A(i,0), ai1 = A(i,1), ai2 = A(i,2), ai3 = A(i,3);
96
94
 
148
146
{
149
147
    GLVector  result;
150
148
    const float *a = lhs.m;
151
 
    int         i;
152
149
 
153
 
    for (i = 0; i < 4; i++)
 
150
    for (int i = 0; i < 4; i++)
154
151
    {
155
152
        result[i] = A(i,0) * rhs[0] + A(i,1) * rhs[1] +
156
153
                    A(i,2) * rhs[2] + A(i,3) * rhs[3];
170
167
bool GLMatrix::invert ()
171
168
{
172
169
    float inv[16], det;
173
 
    int i;
174
170
 
175
171
    inv[0] =   m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15]
176
172
             + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
211
207
 
212
208
    det = 1.0f / det;
213
209
 
214
 
    for (i = 0; i < 16; i++)
 
210
    for (int i = 0; i < 16; i++)
215
211
        m[i] = inv[i] * det;
216
212
 
217
213
    return true;