From 21f8e588da367f19096cc976f037a0855d5f3996 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 16 Sep 2014 15:30:01 +0200 Subject: [PATCH] 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. --- src/kits/network/libnetapi/Url.cpp | 38 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/kits/network/libnetapi/Url.cpp b/src/kits/network/libnetapi/Url.cpp index 3bfd4e31a5..76a050d262 100644 --- a/src/kits/network/libnetapi/Url.cpp +++ b/src/kits/network/libnetapi/Url.cpp @@ -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; + }