The pattern of "create a new instance in order to execute function X exactly once" involves a lot of churn with object creation and destruction, even if escape analysis will optimize the object allocation to the stack instead of the heap. It would be better to convert classes like Comparator and Modifier to only use static functions that accept the Semver instance that they're working with as the first argument.
The pattern of "create a new instance in order to execute function X exactly once" involves a lot of churn with object creation and destruction, even if escape analysis will optimize the object allocation to the stack instead of the heap. It would be better to convert classes like
ComparatorandModifierto only use static functions that accept theSemverinstance that they're working with as the first argument.