Optimization - calculate the subnet prefix only once.