Speed Optimization for Edit Distance