Reduce overhead of char[] creation
There are more locations which could benefit from not using a toCharArray on a String, but rather use the charAt method from the String itself. This to prevent an additional copy of the char[] being created.
This commit is contained in:
committed by
Juergen Hoeller
parent
9139cb85bd
commit
c9b27af64f
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -225,11 +225,11 @@ public final class Conventions {
|
||||
if (!attributeName.contains("-")) {
|
||||
return attributeName;
|
||||
}
|
||||
char[] chars = attributeName.toCharArray();
|
||||
char[] result = new char[chars.length -1]; // not completely accurate but good guess
|
||||
char[] result = new char[attributeName.length() -1]; // not completely accurate but good guess
|
||||
int currPos = 0;
|
||||
boolean upperCaseNext = false;
|
||||
for (char c : chars) {
|
||||
for (int i = 0; i < attributeName.length(); i++ ) {
|
||||
char c = attributeName.charAt(i);
|
||||
if (c == '-') {
|
||||
upperCaseNext = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user