ywywdh / papervision3d

Automatically exported from code.google.com/p/papervision3d
0 stars 0 forks source link

Enhancement: Speed up ViewportObjectFilter.testObject #168

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On lines 28-44, we can potentially speed up the calculation by reducing the
number of if/else checks.

Since INCLUSIVE and EXCLUSIVE are ints 0 and 1, respectively, we can write
the code like this:

if (objects[object]){
    return 1-mode;
} else {
    return mode;
}

I am unsure if 1-mode is faster than if check, but we can profile it to
make sure. In any case, the else case should be faster.

This makes the code harder to read, :-( but might help speed up code that
relies on ViewportObjectFilters...

Original issue reported on code.google.com by ron...@gmail.com on 30 Jan 2009 at 6:29

GoogleCodeExporter commented 9 years ago
Nice find.  If anything it does reduce the number of checks.  

Original comment by azu...@gmail.com on 4 Mar 2009 at 2:23