You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Debug formatting leads to less desireable output #215
I think the current algorithm used for debug output is to loop over all flags and append identifiers that correspond to set bits. I think an alternative here that could work would be to short-circuit when we’ve built a format that covers all the set bits. As an implementation note we wouldn’t be able to work off a single source and just mask out bits as we see them, we’ll need to use the whole set of bits to see if a flag is applicable and then a second set that’s masked to see when we’ve catered for all set bits. Otherwise something like this wouldn’t work:
const A: 0b00000100
const B: 0b00001100
let input = B;
we’d mask out bit 3 for A but then have one leftover for B that doesn’t correspond to it. In that example we’d end up writing A | B still, but wouldn’t duplicate compound identifiers the same.
In general, I’m not sure if there’s a reasonable algorithm that would produce the smallest possible format for any given set of bits.
Activity
KodrAus commentedon Oct 25, 2021
I think the current algorithm used for debug output is to loop over all flags and append identifiers that correspond to set bits. I think an alternative here that could work would be to short-circuit when we’ve built a format that covers all the set bits. As an implementation note we wouldn’t be able to work off a single source and just mask out bits as we see them, we’ll need to use the whole set of bits to see if a flag is applicable and then a second set that’s masked to see when we’ve catered for all set bits. Otherwise something like this wouldn’t work:
we’d mask out bit 3 for
Abut then have one leftover forBthat doesn’t correspond to it. In that example we’d end up writingA | Bstill, but wouldn’t duplicate compound identifiers the same.In general, I’m not sure if there’s a reasonable algorithm that would produce the smallest possible format for any given set of bits.