Apache OpenOffice (AOO) Bugzilla – Issue 100172
performance: framework::KeyMapping should be reused
Last modified: 2009-05-08 10:01:09 UTC
While debugging into issue 98052 I noticed that a lot of cycles in that use case (first keypress in empty Writer) are completely wasted by framework::KeyMapping objects. Since the implementation of that class only seems to deal with constant data rebuilding the key<->name maps shouldn't be done each time. Also the query methods in that class should be const-ified, as they don't change the KeyMapping object. Maybe the class should be pImpled and the const pImpl-entation should be reused. Especially the method XCUBasedAcceleratorConfiguration::impl_ts_load() seems to be infamous for constructing/destructing the currently expensive KeyMapping object over and over. In the use case mentioned above (first keypress in Writer) this was done 5460 times!!! Here is a simple patch to reduce the thousands of invocations to one by reusing the (to-be const) object: --- a/framework/source/accelerators/acceleratorconfiguration.cxx +++ b/framework/source/accelerators/acceleratorconfiguration.cxx @@ -1287,1 +1287,1 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( sal_Bool bPreferred, const - KeyMapping aKeyMapping; + static KeyMapping aKeyMapping;
cd->wuyan: Could you please have a look at this issue. This is a performance problem for all platforms although the Mac is hurt most.
@hdu : I discussed the point two days ago with pl, and you come with a patch :) I'll test it immediately, because I'm very curious to see this problem solved.
+me on CC
cd->hdu: As discussed by phone. KeyMapping can be removed from the inner loop. You can also make this variable static. cd: Add regression keyword. Ok in OOo 3.0.1.
wuyan->cd,hdu: THANKS for the patch. Just as methioned aboved, much resource was consumed due to the KeyMapping ctor/dtor in the loop but I ignored that. Both the two solutions could solve this problem.
cd: Set correct target. Approved as show stopper.
code change reviewed => ok
cd: Fixed.
cd->sba: Please verify.
Verified in CWS fwk106.
OK in OOO310_m11 (OOo 3.1). Closed.