java-html-sanitizer icon indicating copy to clipboard operation
java-html-sanitizer copied to clipboard

PolicyFactory / fast copy constructor or method

Open JohannesLichtenberger opened this issue 4 years ago • 2 comments

Would it be possible to add a fast copy-method or copy-constructor to the PolicyFactory class. The method

public PolicyFactory and(PolicyFactory f)

seems to be relatively slow and we have to reset the PolicyFactories often times. Thus it would probably be an option to copy the initial concatenation of all PolicyFactories and use something like a fast copy method to reset the factories to the initial state.

JohannesLichtenberger avatar Jan 27 '21 10:01 JohannesLichtenberger

PolicyFactory instances have no mutable state, so creating a copy doesn't do very much.

There is nothing intrinsic in PolicyFactory that needs resetting. What are you doing?

I can see a reason for stateful pre- and post-processors. Is that what you are resetting?

simon-greatrix avatar Feb 06 '21 15:02 simon-greatrix

I'm doing a bunch of and-method calls to add policies. A user then might add further optional policies. In a rendering pipeline the configuration gets resettet to the initial state sometimes and apparently regarding CPU profile samples in YourKit the and-method seems to be costly.

JohannesLichtenberger avatar Feb 08 '21 01:02 JohannesLichtenberger