theigl opened a new pull request #451: URL: https://github.com/apache/wicket/pull/451
I made some initial tweaks to `Behaviors.getBehaviors()` in #422 but my profiler still shows a suspicious amount of allocation coming from this method. I overlooked one big potential improvement when I tried to improve the method the last time: The `ArrayList` that holds the behaviors is *always* initialized, even if we know that the component has no data. It is initialized with zero elements, but the overhead is still noticeable. I adjusted the method to return early in case there is no data and I'm lazily initializing the list in case there are no behaviors or no behaviors of the requested type. **Branch** Benchmark | Mode | Cnt | Score | Units ------------ | ------------- | ------------- | --: | ------------- Behaviors.noData | thrpt | 3 | 370553147,400 | ops/s Behaviors.onlyBehavior | thrpt | 3 | 79380410,149 | ops/s Behaviors.onlyMetaData | thrpt | 3 | 313669759,421 | ops/s Behaviors.onlyModel | thrpt | 3 | 291586063,270 | ops/s Behaviors.noMatch | thrpt | 3 | 251464191,584 | ops/s Behaviors.detach | thrpt | 3 | 1521371870,081 | ops/s **Master** Benchmark | Mode | Cnt | Score | Units ------------ | ------------- | ------------- | --: | ------------- Behaviors.noData | thrpt | 3 | 317804308,641 | ops/s Behaviors.onlyBehavior | thrpt | 3 | 72185072,343 | ops/s Behaviors.onlyMetaData | thrpt | 3 | 189207127,567 | ops/s Behaviors.onlyModel | thrpt | 3 | 207693228,485 | ops/s Behaviors.noMatch | thrpt | 3 | 208174862,835 | ops/s Behaviors.detach | thrpt | 6 | 1248153050,802 | ops/s ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org