CodeSOD: Polynomial Optimization |
Rayer Ss co-worker exploded into his cube, beaming. Ive just optimized our processing loop. Ive gone from O(n2) to O(n)!
Thats amazing ! The processing loop in question was easily the most expensive part of the application, and Rayer had been spending too much time finding ways to squeeze a little performance out of it. How did you do it?
The original code looked something like this:
for(int i = 0; i < m; ++i) {
for(int j = 0; j < n; ++j) {
process(target[i][j]); //this is really expensive
}
}
It was a fairly standard nested loop operation.
Radar pulled the new version from source control to see his co-workers genius.
for(int i = 0; i < m * n; ++i) {
process(*((target*)(&target) + i));
}
Radar complimented his co-worker on his understanding of C++ pointers, but had some negative things to say about his understanding of basic arithmetic.
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |