Re:A quick look at the Redis source code
by HeyChinaski on Tuesday October 15, 2013 @06:00PM
(#6556659)
In defence of the technique, the command table is quite succinct and arguably more readable at a glance than if there were a bunch of constants |ed together. I have no idea whether this was the original motivation though.
Re:A quick look at the Redis source code
by GhotiFish on Tuesday October 15, 2013 @06:07PM
(#6556702)
Yes. It is certainly more pithy.
ACTUALLY! It reminds me of a technique Bisqwit used when he made his emulator. He used strings to define the behavior of certain instructions, the strings were actually interpreted at compile time. Though I think this is a C++ specific trick.
http://www.youtube.com/watch?v=y71lli8MS8s
he brings in the instruction table at 1:30
I'm sure there's a good reason, but this style seems strange to me.
Maybe redis makes use of the string later? but I can't help but feel it should build the string based on the flags, rather than build the flags based on the string.