Avoid unnecessary char casts for CookieEncoder (#8827)
Motivation: Avoid unnecessary (char) casts by changing variables types. Modifications: Use chars directly. Result: Less casts.
This commit is contained in:
parent
dd88f0ec48
commit
da45e07e80
@ -97,24 +97,24 @@ final class CookieUtil {
|
||||
|
||||
static void add(StringBuilder sb, String name, long val) {
|
||||
sb.append(name);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append('=');
|
||||
sb.append(val);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SP);
|
||||
sb.append(';');
|
||||
sb.append(HttpConstants.SP_CHAR);
|
||||
}
|
||||
|
||||
static void add(StringBuilder sb, String name, String val) {
|
||||
sb.append(name);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append('=');
|
||||
sb.append(val);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SP);
|
||||
sb.append(';');
|
||||
sb.append(HttpConstants.SP_CHAR);
|
||||
}
|
||||
|
||||
static void add(StringBuilder sb, String name) {
|
||||
sb.append(name);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SP);
|
||||
sb.append(';');
|
||||
sb.append(HttpConstants.SP_CHAR);
|
||||
}
|
||||
|
||||
static void addQuoted(StringBuilder sb, String name, String val) {
|
||||
@ -123,12 +123,12 @@ final class CookieUtil {
|
||||
}
|
||||
|
||||
sb.append(name);
|
||||
sb.append((char) HttpConstants.EQUALS);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append('=');
|
||||
sb.append('"');
|
||||
sb.append(val);
|
||||
sb.append((char) HttpConstants.DOUBLE_QUOTE);
|
||||
sb.append((char) HttpConstants.SEMICOLON);
|
||||
sb.append((char) HttpConstants.SP);
|
||||
sb.append('"');
|
||||
sb.append(';');
|
||||
sb.append(HttpConstants.SP_CHAR);
|
||||
}
|
||||
|
||||
static int firstInvalidCookieNameOctet(CharSequence cs) {
|
||||
|
@ -105,10 +105,10 @@ public final class ServerCookieEncoder extends CookieEncoder {
|
||||
add(buf, CookieHeaderNames.MAX_AGE, cookie.maxAge());
|
||||
Date expires = new Date(cookie.maxAge() * 1000 + System.currentTimeMillis());
|
||||
buf.append(CookieHeaderNames.EXPIRES);
|
||||
buf.append((char) HttpConstants.EQUALS);
|
||||
buf.append('=');
|
||||
DateFormatter.append(expires, buf);
|
||||
buf.append((char) HttpConstants.SEMICOLON);
|
||||
buf.append((char) HttpConstants.SP);
|
||||
buf.append(';');
|
||||
buf.append(HttpConstants.SP_CHAR);
|
||||
}
|
||||
|
||||
if (cookie.path() != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user