Case 1:
ssadd does a check if the entity exists in the set, you can change
CASE 1
(setq ss (ssadd))
(if (not (ssmemb n ss))
(ssadd n ss)
;code
);if
to
CASE 1
(ssadd n ss)
;code
Often in code optimisation is rarely a single line that makes a difference... unless you are doing thousands of calculations, so here taking out an if statement won't do a lot. Most likely you have a loop within a loop that slows things - might be more efficient to look back at how you are selecting the entities and processing them before adding to the selection set. However don't just accept that, if you code will work without the line take out your if statement, and ssadd and you shouldn't really notice a big difference in speed