I will look at my trip and see what airports I am passing through, what time, what hotels I'll be staying, what time will I get there, is there anything open near or at the hotel? If it looks bad, I will take some stuff in my flight kit...bananas, bagels, tuna/cracker kits or anything non-perishable, easy to pack and eat in the cockpit or hotel. I even brought an MRE one time.
I hate getting to a hotel room late and no food service is available. Also, it's not just about saving money, but saving time. I have wandered into many terminals to find nothing but long lines. When you're starving and on a quick turn, long lines are the last thing you need.