This kind of situation is what bean dipping and all the "special phrases" discussed on this board are made for.
When trying to remain diplomatic and polite, less is more and vague is better.
If you do not want to lie, then stick to bare facts and keep all those messy opinions and non-ehell approved responses in your head.
Bad Sub: "Didn't I sub for your class?"
You think:Yes, and you were horrible.
: "It's possible**. [insert bean dip about performance or buffet etc. here]"
** = because technically anything is possible.
Another possible (technical/diplomatic) 'truth':
*Lightly*"Oh, I don't remember every teacher that subs for me. [Insert bean dip or if you're feeling generous a polite inquiry about what he is doing now, to avoid the horrible things you know he's done in the past]" - yes you remember him but it is a bad memory so it does not count for the sake of polite conversation
I don't think you have to lie to avoid an uncomfortable conversation or confrontation, but IMHO the "lie" you told about your sudden "amnesia" regarding this loser is acceptable in polite circles when the truth simply cannot be discussed politely. If someone is trying to bring up an uncomfortable topic, it is perfectly acceptable to smile and say "I don't recall."
Being civil and polite can sometimes mean smiling when you want to scream, saying 'hello' when you'd rather say 'goodbye', and making neutral small talk with a jerk in the buffet line when you'd rather stab him in the eye with your fork.
You did wonderfully under pressure (spur of the moment no less!) and didn't go for the fork option, so I applaud you.