[Libreoffice] rtl_alloc_cache microopt question (& patch)

Sebastian Spaeth Sebastian at SSpaeth.de
Fri Nov 26 04:42:29 PST 2010


As rtl_alloc_cache is called 600k times on writer startup I looked at
it. 

I made the function somewhat simpler to read by removing an indention
level (unfortunately making the diff harder to read), and also tried to
microoptimize a tiny bit.

Would the compiler be smart enough to optimize this on compilation to
identical code or is the new one a tiny tad nicer?

-    if (n >= SAL_MAX_SIZE - (RTL_MEMALIGN + RTL_MEMALIGN - 1))
+    if (n > SAL_MAX_SIZE - 2 * RTL_MEMALIGN

I reran with callgrind and it *seemed* to use a bit less CPU
instructions but I am not experienced enough to really judge this.

The new code is easier to read in any case (I think). Would someone have
a quick look at the patch?



More information about the LibreOffice mailing list