My code is not that brute force. It does not try all possible opponent moves. It limits itself to checking whether each enemy piece can move to the King's position. So, it checks no more than one move per enemy piece. Second, it returns a true value as soon as the first check is found.
That is a very good method for most pieces. The problem is that I have to be completely general, as users can in principle define sliders that turn corners, such as the Sissa or the Hook Mover from the large Shogi variants.
This would depend on how those pieces are defined. If they are treated as making two separate moves on the same turn, and the second move is capable of checking the King, things could prove difficult. If their move is treated as a single move that requires a turning point, or checking is allowed only on the first part of a move, then it's not a problem. There could even be a hybrid solution, in which the piece has a checking-only move that completes the whole move, but it otherwise handles actual moves as a pair of separate moves.
This would depend on how those pieces are defined. If they are treated as making two separate moves on the same turn, and the second move is capable of checking the King, things could prove difficult. If their move is treated as a single move that requires a turning point, or checking is allowed only on the first part of a move, then it's not a problem. There could even be a hybrid solution, in which the piece has a checking-only move that completes the whole move, but it otherwise handles actual moves as a pair of separate moves.