New Tiled Data Manager ideas and tests

Bart Coppens kde at bartcoppens.be
Tue Jun 2 17:51:06 CEST 2009


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 at 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 at tuvok-debian:~/pruts$ g++ -o constint constint.cc && ./constint
1 1
1 2


Bart


More information about the kimageshop mailing list