3 ms·
It won't execute more than one, because only one can match. The other sscanfs will all fail. I agree it would make sense to stop trying patterns once one has ma
by mtdewcmu 11y ago
It won't execute more than one, because only one can match. The other sscanfs will all fail. I agree it would make sense to stop trying patterns once one has matched, though.
Personally, my inclination would be to rewrite the loop to tighten it up. But maybe the point was to show how quickly and dirtily one can do this... it definitely looks quick and dirty.
- wkoszek 11y agoQuick, dirty and primitive was my primary motivation for this exercise :-)
- rootlocus 11y agoHow would you rewrite it to "tighten it up"?
- mtdewcmu 11y agoI would make that series of if-statements more obviously deterministic, for starters. One way of accomplishing that would be a bunch of nested if-else blocks. However, that would be ugly. I'd prefer something like continue statements -- which would necessitate redesigning the loop to avoid bypassing the code at the bottom. Either way, the way this currently gives the appearance of being possibly nondeterministic makes me uncomfortable... and besides, executing those extra conditionals wastes CPU cycles.