Code snippet optimization