Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 55b258f

Browse files
dreis2211sbrannen
authored andcommittedNov 8, 2022
Avoid unnecessary allocations in StompDecoder#unescape
Closes gh-29443
1 parent f4b3333 commit 55b258f

File tree

1 file changed

+5
-2
lines changed
  • spring-messaging/src/main/java/org/springframework/messaging/simp/stomp

1 file changed

+5
-2
lines changed
 

‎spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -264,9 +264,12 @@ private void readHeaders(ByteBuffer byteBuffer, StompHeaderAccessor headerAccess
264264
* <a href="https://stomp.github.io/stomp-specification-1.2.html#Value_Encoding">"Value Encoding"</a>.
265265
*/
266266
private String unescape(String inString) {
267+
int index = inString.indexOf('\\');
268+
if (index == -1) {
269+
return inString;
270+
}
267271
StringBuilder sb = new StringBuilder(inString.length());
268272
int pos = 0; // position in the old string
269-
int index = inString.indexOf('\\');
270273

271274
while (index >= 0) {
272275
sb.append(inString, pos, index);

0 commit comments

Comments
 (0)
Please sign in to comment.