It matters a lot whether it is fired or laid off. If you're going to be laid off, that doesn't look bad to future employers, you're eligible for unemployment, and you should never quit first.
If you're going to be fired, that's not so clear cut. Both quitting and being fired look bad to potential employers. And you generally look more attractive to future employers when you have a job, so cutting loose early only gives an advantage in giving you more time to look for the next job. You are sometimes eligible for unemployment even when fired.
If you work for an employer that fires for flaky reasons, it might be better to keep working well, and wait for the firing. A reputation like that gets around, and it's not as much of a disgrace to be fired from a place like that.
If you're truly a bad worker and deserve firing, then perhaps being a quitter won't look as bad. If you can give a good justification for leaving the job without another, that could be your best bet.
(I once left a job without another because of family issues that needed my attention. A reason like that used for leaving a job doesn't look as bad. It's not great, but not terrible either.)