garydgregory commented on PR #1886: URL: https://github.com/apache/commons-lang/pull/1886#issuecomment-6987988314
@joao-jordy Thanks for the contribution. The repeated substring copying is a real inefficiency, and the proposed optimization is sound. I reworked the change locally to strengthen the tests and support the performance claims: The new test describes a 1,000-dimensional array name as valid, but the JVM limit is 255 dimensions. I added coverage within that limit and kept the larger input as a separate, explicitly unchecked-input case. The new assertion also passes with the original implementation, so it verifies output preservation rather than detecting the performance regression. It only covers a reference array; I expanded the direct `String` overload tests to cover primitive arrays, nested-class arrays, and existing bracket-only exception behavior. The existing `Class<?>` array tests exercise a separate implementation. The reported 200,000-bracket timing demonstrates the copying problem, but uses input outside the documented valid-name domain. I added a JMH benchmark covering valid class names and array depths so the practical effects can be measured reproducibly. I also simplified the implementation slightly: counting brackets and building the suffix can happen in the same loop, followed by a single `substring` call. This avoids the additional loop introduced by the PR. Closing, see commit 77f62098415696b103bd7c83dc61e98cbe9110c2, you are credited in `changes.xml`. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
