This doesn't make sense. "Is on screen" works fast, I tested it with 10000 objects and it didn't make any noticeable difference in performance. Definitely shouldn't matter for 50 objects.
In your case you don't really need this check, because you are only changing a bunch of variables. It's useful when you have CPU-intensive behaviors applied on objects, like Platform or Physics. Then you can disable these behaviors when objects are off-screen and improve performance.
I don't know why your code runs faster with this condition disabled. I'm guessing that off-screen object instances have empty values in these variables (direction, animation, lastX, lastY) and some other events don't work effectively with them.