Issue #23107:  Tighten-up loops in setobject.c

* Move the test for an exact key match to after a hash match
* Use "used" as a loop counter instead of "fill"
* Minor improvements to variable names and code consistency
Small clean-up.  Factor-out common code for add, contains, and discard function pairs.