Use file-local statics, not function-local.

Function local statics involve locking for initialization, file-local statics do
not.

Thanks to @pippijn for the hint.