Text this: Cost, efficiency, and the optimal number of firms in spatial markets