[En-Nut-Discussion] heap.c code optimization

Dusan Ferbas dferbas at dfsoft.cz
Sat Jan 15 22:33:58 CET 2005


Hi guys,

how do you like sitting following piece of code in your applications ? 
(os/heap.c:NutHeapAlloc)

>     while ((size & 0x03) != 0)
>         size++;

What about to change it to

         size = (size + 3) & ~((size_t)0x03);

I do not know exactly how it'll be compiled on various platforms but I feel 
it can be quicker.


Dusan  




More information about the En-Nut-Discussion mailing list