Optimized code for parsing module names