This is an automated email from the ASF dual-hosted git repository.
theigl pushed a commit to branch wicket-9.x
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/wicket-9.x by this push:
new 9548caa WICKET-6960 Avoid unnecessary allocations when decoding and
encoding `ComponentInfo` (#501)
9548caa is described below
commit 9548caa2db46a12e89d1ec2b934af4e5b0dba0e6
Author: Thomas Heigl <[email protected]>
AuthorDate: Sun Mar 6 12:35:33 2022 +0100
WICKET-6960 Avoid unnecessary allocations when decoding and encoding
`ComponentInfo` (#501)
(cherry picked from commit d902cdbdd853cb490db1507d79c587acede01ae3)
---
.../apache/wicket/request/mapper/info/ComponentInfo.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git
a/wicket-request/src/main/java/org/apache/wicket/request/mapper/info/ComponentInfo.java
b/wicket-request/src/main/java/org/apache/wicket/request/mapper/info/ComponentInfo.java
index 6afa70b..909d8dc 100644
---
a/wicket-request/src/main/java/org/apache/wicket/request/mapper/info/ComponentInfo.java
+++
b/wicket-request/src/main/java/org/apache/wicket/request/mapper/info/ComponentInfo.java
@@ -47,8 +47,12 @@ public class ComponentInfo
{
if (path != null)
{
- StringBuilder result = new StringBuilder();
int length = path.length();
+ if (length == 0)
+ {
+ return path.toString();
+ }
+ StringBuilder result = new StringBuilder(length);
for (int i = 0; i < length; i++)
{
char c = path.charAt(i);
@@ -83,8 +87,12 @@ public class ComponentInfo
{
if (path != null)
{
- StringBuilder result = new StringBuilder();
int length = path.length();
+ if (length == 0)
+ {
+ return path.toString();
+ }
+ StringBuilder result = new StringBuilder(length);
for (int i = 0; i < length; i++)
{
char c = path.charAt(i);
@@ -188,13 +196,13 @@ public class ComponentInfo
*/
private static boolean isNumber(final String string)
{
- if ((string == null) || (string.length() == 0))
+ if (string == null || string.isEmpty())
{
return false;
}
for (int i = 0; i < string.length(); ++i)
{
- if (Character.isDigit(string.charAt(i)) == false)
+ if (!Character.isDigit(string.charAt(i)))
{
return false;
}