Optimization for short masks: Avoid repeated strlen's that the
optimizer would not dare taking away as written. Also make key
a const char* so we don't screw up.