Hacker News new | ask | show | jobs
by RiderOfGiraffes 5716 days ago
If you're handed a bit mask of events or flags then it can be used to iterate through the bits that are set, rather than all the bits.

    while flags!=0:
        right_most = flags & (-flags)
        process(right_most)
        flags &= ~right_most