On Mon, 2004-08-02 at 19:20, bulia byak wrote:
I found that Inkscape runs 6% to 7% faster if I replace in nr-point.h
Coord operator[](unsigned i) const throw(std::out_of_range) { if ( i > Y ) { throw std::out_of_range("index out of range"); } return _pt[i]; }
with
inline Coord operator[](unsigned i) const { return _pt[i]; }
Well, I think that you are making two changes here. One that removes the check, and one that make the function inline. I'm guessing that the inline is the reason for the speed up, not removing the check. I think that this function is called in two ways. One directly: mypoint[X] and one from a loop: for(int i = 0; i < 2; i++) mypoint[i]. In both cases the compiler will optimize out the check (in the later it will have to happen after the loop is unrolled) if the function is inline.
Ofcourse, measured results trump theoretical ones. But I'm guessing the inline is the larger speed up. It would be nice to keep the check in if it isn't high cost.
--Ted