How to speed inside ofpolyline when using inside

Hello everyone, I’m using ofpolyline inside to deal with polyline range of pixels, but each time is always very slow, what can I do to speed up the processing speed,Thanks.

Hi, please provide some code in order to help, as with the info you provide is quite hard.