This is unnecessarily complicated
really!
and I don’t see how your second version is supposed to be more optimal?
It was a half-joke. But since you asked, It doesn't do any duplicate range checks.
But it's not like any of this is going to be measurable.
Things you should/could have complained about:
- [semantics] not checking if
handlare in the [0, 9] range before taking the result ofh*10 + l. - [logical consistency] not using a set bet for [0, 100] and a set bit for [1, 12], and having both bits set for the latter.
- [cosmetic/visual] not having the props bits for p0 on the left in the switch.
And as a final note, you might want to check what kind of code compilers actually generate (with -O2/-O3 of course). Because your complaints don't point to someone who knows.
I don't do Go (thankfully). But that description reminded me of "A False Midnight", which is a Python story from almost 12 years ago (time flies).
The fact that these two stories concern Python and Go, the two supposedly easy and simple languages, are good examples of why such descriptors were always intellectual smell.