Skip to content

Commit d2e2482

Browse files
committed
Merge pull request sendgrid#68 from pbdeuchler/cache_string_during_conditionals
Caches email.smtpapi.jsonString() so we only have to call it once
2 parents 5b6b27b + b1fcc79 commit d2e2482

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/com/sendgrid/SendGrid.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ public HttpEntity buildBody(Email email) {
139139
if (email.getText() != null && !email.getText().isEmpty())
140140
builder.addTextBody(PARAM_TEXT, email.getText(), ContentType.create("text/plain", "UTF-8"));
141141

142-
if (!email.smtpapi.jsonString().equals("{}"))
143-
builder.addTextBody(PARAM_XSMTPAPI, email.smtpapi.jsonString(), ContentType.create("text/plain", "UTF-8"));
142+
String tmpString = email.smtpapi.jsonString();
143+
if (!tmpString.equals("{}"))
144+
builder.addTextBody(PARAM_XSMTPAPI, tmpString, ContentType.create("text/plain", "UTF-8"));
144145

145146
return builder.build();
146147
}

0 commit comments

Comments
 (0)