Optimize Path2D polyfill