arturobernalg commented on code in PR #437:
URL: 
https://github.com/apache/httpcomponents-core/pull/437#discussion_r1342183980


##########
httpcore5/src/main/java/org/apache/hc/core5/http/message/BufferedHeader.java:
##########
@@ -110,7 +113,27 @@ public String getName() {
 
     @Override
     public String getValue() {
-        return this.buffer.substringTrimmed(this.valuePos, 
this.buffer.length());
+        if (value == null) {
+            int beginIdx = valuePos;
+            int endIdx = buffer.length();
+            while (beginIdx < buffer.length() && 
Tokenizer.isWhitespace(buffer.charAt(beginIdx))) {
+                beginIdx++;
+            }
+            while (endIdx > beginIdx && 
Tokenizer.isWhitespace(buffer.charAt(endIdx - 1))) {
+                endIdx--;
+            }
+            final StringBuilder buf = new StringBuilder(endIdx - beginIdx);
+            for (int i = beginIdx; i < endIdx; i++) {
+                final char ch = buffer.charAt(i);
+                if (ch == Chars.CR || ch == Chars.LF || ch == 0) {
+                    buf.append(' ');

Review Comment:
   Using `(char) Chars.SP` instead of ' ' should not degrade the performance 
and would be clearer.I mean, 
   `  for (int i = beginIdx; i < endIdx; i++) {
                   final char ch = buffer.charAt(i);
                   if (ch == Chars.CR || ch == Chars.LF || ch == Chars.NUL) {
                       buf.append((char) Chars.SP);
                   } else {
                       buf.append(ch);
                   }
               }`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to