[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Re: New Tiled Data Manager ideas and tests
From:       Bart Coppens <kde () bartcoppens ! be>
Date:       2009-06-02 15:51:06
Message-ID: 200906021751.06310.kde () bartcoppens ! be
[Download RAW message or body]

On Tuesday 02 June 2009 17:25:58 Dmitry Kazakov wrote:
> New commit r976769
(For reference:
http://websvn.kde.org/branches/work/koffice-feature-tiles-ng/krita/image/tiles3/kis_tile_processors.cc?r1=976769&r2=976768&pathrev=976769
 )

> A strange thing! I changed only one line and processors started working 20%
> faster than old system. I don't know why. Could someone take a look.
Well it is probably because you change the meaning of the variable. In the old 
version (const qint32 dataIdx), your variable is constant across the duration 
of the function. In the new version, (static const qint32 dataIdx) the 
variabe is constant for _all_ invocations of the function (after the first 
one).

Observe:
bartcopp@tuvok-debian:~/pruts$ cat constint.cc
#include <iostream>
using namespace std;

int foo(int arg) { return arg + 1; }

int fun1(int arg) {
    static const int val = arg;
    return val;
}

int fun2(int arg) {
    const int val = arg;
    return val;
}

int main() {
    cout << fun1(1); cout << " " << fun1(2) << endl;
    cout << fun2(1); cout << " " << fun2(2) << endl;
}
bartcopp@tuvok-debian:~/pruts$ g++ -o constint constint.cc && ./constint
1 1
1 2


Bart
_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic