https://bz.apache.org/bugzilla/show_bug.cgi?id=59773

            Bug ID: 59773
           Summary: Move loop invariants outside of loop for faster
                    execution
           Product: POI
           Version: 3.15-dev
          Hardware: Other
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: POI Overall
          Assignee: [email protected]
          Reporter: [email protected]

POI has a fair amount of code that reads
for(int i=0; i<getNumberOfStyles(); i++) {
    // do something
}

The call to getNumberOfStyles is called for every loop iteration. At best this
is a lot of function calls. At worst, this is a lot of expensive function
calls.

We can pretty easily find cases where we can make POI faster by moving loop
invariants (value doesn't change over the for loop, function doesn't have any
side-effects) outside the loop.

grep -r --exclude-dir=".svn" -P "for\s*\([^:\(]+\(\)[^:\)]+\)"

This finds function calls within a for loop, excluding for-each loops.

There are currently 514 instances. Some may be for-loops over iterators or
functions with side-effects. The rest could probably be made faster without
harming readability.

There are likely expressions or functions that are re-evaluated with loops that
could be pulled out of an inner loop or loops entirely, but this is a bit
trickier to find with a reg ex.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to