Micro optimization in wxInternetFSHandler::OpenFile()

Avoid copying the content type string unnecessarily and avoid even
calling GetContentType() in the first place in case of an error.
This commit is contained in:
Vadim Zeitlin
2019-01-03 23:15:54 +01:00
parent e287344b78
commit 9f270c05ff

View File

@@ -105,7 +105,6 @@ wxFSFile* wxInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs),
if (url.GetError() == wxURL_NOERR)
{
wxInputStream *s = url.GetInputStream();
wxString content = url.GetProtocol().GetContentType();
if (s)
{
wxString tmpfile =
@@ -120,6 +119,7 @@ wxFSFile* wxInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs),
// Content-Type header, as defined by the RFC 2045, has the form of
// "type/subtype" optionally followed by (multiple) "; parameter"
// and we need just the MIME type here.
const wxString& content = url.GetProtocol().GetContentType();
wxString mimetype = content.BeforeFirst(';');
mimetype.Trim();