Have you considered making the builder object immutable, so that every fluent method returned a new instance, and a finalize method returned a regular RegExp?
Not really. Didn't want to hit performance that hard for so simple task. But it makes me think, maybe provide something like .clone() method for cloning the already constructed RegExp and extending it later?
Have you considered making the builder object immutable, so that every fluent method returned a new instance, and a finalize method returned a regular RegExp?
Not really. Didn't want to hit performance that hard for so simple task. But it makes me think, maybe provide something like
.clone()
method for cloning the already constructed RegExp and extending it later?You wouldn't hit it as hard as you think, since in the absence of mutable methods you would reuse most of the tree.
In this case, I will consider it as an option. Of course it would be quite a breaking change.