diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-06-27 23:38:30 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-06-28 13:53:35 +0100 |
commit | 694e2cbf9da8c0bef6a064d3a12e44c20a693784 (patch) | |
tree | e4f2c9114c3739cea590bd9be2006a257341c3d7 | |
parent | 46d1a28a2ed4ccfcbc8f6edaacd6e56f448dd4ea (diff) |
There's no reason for GetDefaultContentType to be virtual
unroll the logic a bit to simplify the only relevant case and take advantage of
return optimization
Change-Id: I88537e83e8fc6785d3932fb4c591d62319682c9b
-rw-r--r-- | tools/inc/tools/inetmsg.hxx | 2 | ||||
-rw-r--r-- | tools/source/inet/inetmsg.cxx | 30 | ||||
-rw-r--r-- | tools/source/inet/inetstrm.cxx | 8 |
3 files changed, 10 insertions, 30 deletions
diff --git a/tools/inc/tools/inetmsg.hxx b/tools/inc/tools/inetmsg.hxx index ef5dabdc0941..db94ca62f94f 100644 --- a/tools/inc/tools/inetmsg.hxx +++ b/tools/inc/tools/inetmsg.hxx @@ -500,7 +500,7 @@ public: return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); } - virtual void GetDefaultContentType (UniString& rContentType); + UniString GetDefaultContentType (); /** Message container methods. */ diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 4753ce488078..7c5e89193b1f 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -1033,36 +1033,18 @@ void INetMIMEMessage::SetContentTransferEncoding ( /* * GetDefaultContentType. */ -void INetMIMEMessage::GetDefaultContentType (String& rContentType) +UniString INetMIMEMessage::GetDefaultContentType() { - String aDefaultCT ( - "text/plain; charset=us-ascii", RTL_TEXTENCODING_ASCII_US); - if (pParent == NULL) - { - rContentType = aDefaultCT; - } - else + if (pParent != NULL) { String aParentCT (pParent->GetContentType()); if (aParentCT.Len() == 0) - pParent->GetDefaultContentType (aParentCT); + aParentCT = pParent->GetDefaultContentType(); - if (aParentCT.CompareIgnoreCaseToAscii ("message/", 8) == 0) - { - rContentType = aDefaultCT; - } - else if (aParentCT.CompareIgnoreCaseToAscii ("multipart/", 10) == 0) - { - if (aParentCT.CompareIgnoreCaseToAscii ("multipart/digest") == 0) - rContentType.AssignAscii ("message/rfc822"); - else - rContentType = aDefaultCT; - } - else - { - rContentType = aDefaultCT; - } + if (aParentCT.CompareIgnoreCaseToAscii ("multipart/digest") == 0) + return rtl::OUString("message/rfc822"); } + return String("text/plain; charset=us-ascii", RTL_TEXTENCODING_ASCII_US); } /* diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index bb55a7aee493..c06bfef00a1e 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -1349,8 +1349,7 @@ int INetMIMEMessageStream::GetMsgLine (sal_Char *pData, sal_uIntPtr nSize) if (aContentType.Len()) { // Determine default Content-Type. - UniString aDefaultType; - pMsg->GetDefaultContentType (aDefaultType); + UniString aDefaultType = pMsg->GetDefaultContentType(); if (aDefaultType.CompareIgnoreCaseToAscii ( aContentType, aContentType.Len()) == 0) @@ -1380,7 +1379,7 @@ int INetMIMEMessageStream::GetMsgLine (sal_Char *pData, sal_uIntPtr nSize) if (aContentType.Len() == 0) { // Determine default Content-Type. - pMsg->GetDefaultContentType (aContentType); + aContentType = pMsg->GetDefaultContentType(); } eEncoding = GetMsgEncoding (aContentType); } @@ -1739,8 +1738,7 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize) */ if (pMsg->GetContentType().Len() == 0) { - String aDefaultCT; - pMsg->GetDefaultContentType (aDefaultCT); + String aDefaultCT = pMsg->GetDefaultContentType(); pMsg->SetContentType (aDefaultCT); } |