Optimize BUrl copy.

BUrl is passed by value in many places, and we should make sure this is
as efficient as possible. There is little point in initializing all the
strings then overwriting them by using the copy constructor, when we can
set them directly.
This commit is contained in:
Adrien Destugues
2014-09-16 15:30:01 +02:00
parent c98378e51a
commit 21f8e588da
+28 -10
View File
@@ -66,17 +66,35 @@ BUrl::BUrl(const BUrl& other)
:
BArchivable(),
fUrlString(),
fProtocol(),
fUser(),
fPassword(),
fHost(),
fPort(0),
fPath(),
fRequest(),
fHasHost(false),
fHasFragment(false)
fProtocol(other.fProtocol),
fUser(other.fUser),
fPassword(other.fPassword),
fHost(other.fHost),
fPort(other.fPort),
fPath(other.fPath),
fRequest(other.fRequest),
fFragment(other.fFragment),
fUrlStringValid(other.fUrlStringValid),
fAuthorityValid(other.fAuthorityValid),
fUserInfoValid(other.fUserInfoValid),
fHasProtocol(other.fHasProtocol),
fHasUserName(other.fHasUserName),
fHasPassword(other.fHasPassword),
fHasHost(other.fHasHost),
fHasPort(other.fHasPort),
fHasPath(other.fHasPath),
fHasRequest(other.fHasRequest),
fHasFragment(other.fHasFragment)
{
*this = other;
if (fUrlStringValid)
fUrlString = other.fUrlString;
if (fAuthorityValid)
fAuthority = other.fAuthority;
if (fUserInfoValid)
fUserInfo = other.fUserInfo;
}