In MN 19, the Buddha-to-be was meditating with mindfulness. Upon becoming aware of various mind states, he then investigated them to see where these mind states led, thus leading to wisdom.
Then, as I meditated—diligent, keen, and resolute—a malicious thought arose … a cruel thought arose. I understood: ‘This cruel thought has arisen in me. It leads to hurting myself, hurting others, and hurting both. It blocks wisdom, it’s on the side of anguish, and it doesn’t lead to extinguishment.’ When I reflected that it leads to hurting myself … hurting others … hurting both, it went away. When I reflected that it blocks wisdom, it’s on the side of anguish, and it doesn’t lead to extinguishment, it went away. So I gave up, got rid of, and eliminated any cruel thoughts that arose.
Whatever a mendicant frequently thinks about and considers becomes their heart’s inclination. If they often think about and consider sensual thoughts, they’ve given up the thought of renunciation to cultivate sensual thought. Their mind inclines to sensual thoughts. If they often think about and consider malicious thoughts … their mind inclines to malicious thoughts. If they often think about and consider cruel thoughts … their mind inclines to cruel thoughts.