avoid math.max for object allocations on ios