When grabbing the transform of an object, or most components for that matter, you pay a price in computation. See if you can use caching to store your gameObject's transform before passing them into the function.
You can change this line
private bool checkPiece (GameObject targetPiece, int side)
to
private bool checkPiece (Transform targetPiece, int side)