Closed voidpointer0x00 closed 10 months ago
Really appreciate the JMH benchmark but it was not really necessary :) I think the difference is probably very small because the java compiler & JIT are pretty good at optimizing string concatenation.
Thanks for the patch, I am definitely going to merge this one in.
It would be nice if you could fix these minor issues. If not, I will merge it in tomorrow and fix them myself.
I'll do that tomorrow morning (about 10 hours from here) :)
Fixes https://github.com/lenis0012/LoginSecurity/issues/230
I also thought using StringBuilder instead of concatenation would improve method's overall performance, but my JMH benchmark did not confirm this theory. I believe it can only improve RAM consumption, therefore it's a debatable topic: whether to keep the "optimization" changes or not, so I left the initial commit and reverted it in case someone would like to keep a version with better RAM utilization.
The JMH benchmark that I used to test 2b11492b576a086e1a50c0d5f7ccb160c274f717 commit
```java @State(Scope.Benchmark) @Warmup(iterations=1, time=5) @Measurement(iterations=3) @Fork(1) @BenchmarkMode(Mode.Throughput) public class StringBuilderLogFilter { private static final ListBenchmark results on my machine, OpenJDK 17.0.8
``` Benchmark (loginShortcut) (registerShortcut) (shortcutsEnabled) Mode Cnt Score Error Units StringBuilderLogFilter.concatenation /l /reg true thrpt 3 4839956.622 ± 1343710.522 ops/s StringBuilderLogFilter.stringBuilder /l /reg true thrpt 3 3936585.734 ± 4270247.509 ops/s ```