Skip to content

Commit

Permalink
Avoid unnecessary allocations in StompDecoder#unescape
Browse files Browse the repository at this point in the history
Closes gh-29443
  • Loading branch information
dreis2211 authored and sbrannen committed Nov 8, 2022
1 parent f4b3333 commit 55b258f
Showing 1 changed file with 5 additions and 2 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
Expand Down Expand Up @@ -264,9 +264,12 @@ private void readHeaders(ByteBuffer byteBuffer, StompHeaderAccessor headerAccess
* <a href="https://stomp.github.io/stomp-specification-1.2.html#Value_Encoding">"Value Encoding"</a>.
*/
private String unescape(String inString) {
int index = inString.indexOf('\\');
if (index == -1) {
return inString;
}
StringBuilder sb = new StringBuilder(inString.length());
int pos = 0; // position in the old string
int index = inString.indexOf('\\');

while (index >= 0) {
sb.append(inString, pos, index);
Expand Down

0 comments on commit 55b258f

Please sign in to comment.