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:
Dmitriy Dumanskiy 2019-02-25 20:50:19 +02:00 committed by Norman Maurer
parent dd88f0ec48
commit da45e07e80
2 changed files with 16 additions and 16 deletions

View File

@ -97,24 +97,24 @@ final class CookieUtil {
static void add(StringBuilder sb, String name, long val) { static void add(StringBuilder sb, String name, long val) {
sb.append(name); sb.append(name);
sb.append((char) HttpConstants.EQUALS); sb.append('=');
sb.append(val); sb.append(val);
sb.append((char) HttpConstants.SEMICOLON); sb.append(';');
sb.append((char) HttpConstants.SP); sb.append(HttpConstants.SP_CHAR);
} }
static void add(StringBuilder sb, String name, String val) { static void add(StringBuilder sb, String name, String val) {
sb.append(name); sb.append(name);
sb.append((char) HttpConstants.EQUALS); sb.append('=');
sb.append(val); sb.append(val);
sb.append((char) HttpConstants.SEMICOLON); sb.append(';');
sb.append((char) HttpConstants.SP); sb.append(HttpConstants.SP_CHAR);
} }
static void add(StringBuilder sb, String name) { static void add(StringBuilder sb, String name) {
sb.append(name); sb.append(name);
sb.append((char) HttpConstants.SEMICOLON); sb.append(';');
sb.append((char) HttpConstants.SP); sb.append(HttpConstants.SP_CHAR);
} }
static void addQuoted(StringBuilder sb, String name, String val) { static void addQuoted(StringBuilder sb, String name, String val) {
@ -123,12 +123,12 @@ final class CookieUtil {
} }
sb.append(name); sb.append(name);
sb.append((char) HttpConstants.EQUALS); sb.append('=');
sb.append((char) HttpConstants.DOUBLE_QUOTE); sb.append('"');
sb.append(val); sb.append(val);
sb.append((char) HttpConstants.DOUBLE_QUOTE); sb.append('"');
sb.append((char) HttpConstants.SEMICOLON); sb.append(';');
sb.append((char) HttpConstants.SP); sb.append(HttpConstants.SP_CHAR);
} }
static int firstInvalidCookieNameOctet(CharSequence cs) { static int firstInvalidCookieNameOctet(CharSequence cs) {

View File

@ -105,10 +105,10 @@ public final class ServerCookieEncoder extends CookieEncoder {
add(buf, CookieHeaderNames.MAX_AGE, cookie.maxAge()); add(buf, CookieHeaderNames.MAX_AGE, cookie.maxAge());
Date expires = new Date(cookie.maxAge() * 1000 + System.currentTimeMillis()); Date expires = new Date(cookie.maxAge() * 1000 + System.currentTimeMillis());
buf.append(CookieHeaderNames.EXPIRES); buf.append(CookieHeaderNames.EXPIRES);
buf.append((char) HttpConstants.EQUALS); buf.append('=');
DateFormatter.append(expires, buf); DateFormatter.append(expires, buf);
buf.append((char) HttpConstants.SEMICOLON); buf.append(';');
buf.append((char) HttpConstants.SP); buf.append(HttpConstants.SP_CHAR);
} }
if (cookie.path() != null) { if (cookie.path() != null) {