Optimized calculation of distinct API elements