Skip to content

Commit a4613c0

Browse files
authored
Avoid allocating an array on extension validation (#367)
Signed-off-by: Pierangelo Di Pilato <[email protected]>
1 parent 69f0e20 commit a4613c0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/src/main/java/io/cloudevents/core/impl/BaseCloudEventBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ protected static IllegalStateException createMissingAttributeException(String at
197197
* @see <a href="https://github.com/cloudevents/spec/blob/master/spec.md#attribute-naming-convention">attribute-naming-convention</a>
198198
*/
199199
private static boolean isValidExtensionName(String name) {
200-
char[] chars = name.toCharArray();
201-
for (char c : chars)
202-
if (!isValidChar(c)) {
200+
for(int i = 0; i < name.length(); i++) {
201+
if (!isValidChar(name.charAt(i))) {
203202
return false;
204203
}
204+
}
205205
return true;
206206
}
207207

0 commit comments

Comments
 (0)