By the time you have come to that conclusion its likely too late to pull the trigger, they have pulled theirs.
we can all get blindsided. But many times, you see a threat coming in. You see someone walk into the restaurant who isn't dressed for summer, who isn't looking at the menu, who is walking too fast and rigid, whose hands aren't just chilling by their side, and you can quietly unzip the fanny pack or draw weapon (under your shirt) and prepare in case they draw a gun and start threatening people.
If they're pulling a heist or shooting, they're making a monster life decision. They don't have the casual look of most people entering a restaurant, scanning snapchat and seeing what's on the 2 for $4 menu today. face, hands, posture, everything.
If there is 1 bad guy, and 20 customers, and 5 workers (likely the money being their focus), there may be a good chance the aware customer can even the odds a bit. Granted, if a dozen terminator MFers with body armor come in the place blasting, my 40 caliber won't do much. But in most situations, with a drug abusing, insecure desperate person focused on the register, their gun may be pulled but mine will be the concealed one that ideally, they never see.