Feb 27, 2008 02:24
So today is the day I had awaited for the past 6 years I spent at University. I had to optimize a logic equation that wasn't entirely obvious, to save precious bytes of program memory.
ABXY &or ABX¬Y ∨ A¬BX¬Y &or AB¬XY ∨ ¬AB¬XY
≡AX(B ∨ ¬Y) ∨ B¬XY
Which resulted in the following source code
if( ((q_id & NIP_MDNS_QUERY_ID_MASK) == (cs->q_id & NIP_MDNS_QUERY_ID_MASK)
&& q_id != NIP_MDNS_NO_QUERY
&&(c_id == cs->c_id || c_id == NIP_MDNS_NO_CACHE_ID))
|| ( c_id == cs->c_id
&& q_id == NIP_MDNS_NO_QUERY
&& c_id != NIP_MDNS_NO_CACHE_ID)
)
{
...
}
So after all, the theoretic computer science class was no waste of time.
Isn't it beautiful? :-D
diplom,
uni,
thoughts