revert pessimization

revert part of
    commit 113d9bba057b2fd634fcfcebb83a4d92cf41d69f
    Author: Noel Grandin <noel.grandin@collabora.co.uk>
    Date:   Fri Sep 30 09:06:51 2022 +0200
    use more string_view in stoc

<sberg> This is another case of a potential pessimization, for no
gain: The passed in schemeSpecificPart will always be an
OUString, and path may be a view of its full content
(if there is neither authority nor query part).

Change-Id: Ibc60fb1f5f351668ef924e25ee3aeb1d80f6f710
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141205
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2022-10-11 10:36:26 +02:00
parent 4b4160cb1a
commit 99f89d40f7

View File

@ -167,10 +167,10 @@ private:
};
css::uno::Reference< css::uri::XUriReference > parseGeneric(
OUString const & scheme, std::u16string_view schemeSpecificPart)
OUString const & scheme, OUString const & schemeSpecificPart)
{
size_t len = schemeSpecificPart.size();
size_t i = 0;
sal_Int32 len = schemeSpecificPart.getLength();
sal_Int32 i = 0;
bool hasAuthority = false;
OUString authority;
if (len - i >= 2 && schemeSpecificPart[i] == '/'
@ -183,22 +183,22 @@ css::uno::Reference< css::uri::XUriReference > parseGeneric(
++i;
}
hasAuthority = true;
authority = schemeSpecificPart.substr(n, i - n);
authority = schemeSpecificPart.copy(n, i - n);
}
sal_Int32 n = i;
i = schemeSpecificPart.find('?', i);
if (i == std::u16string_view::npos) {
i = schemeSpecificPart.indexOf('?', i);
if (i == -1) {
i = len;
}
std::u16string_view path = schemeSpecificPart.substr(n, i - n);
OUString path = schemeSpecificPart.copy(n, i - n);
bool hasQuery = false;
OUString query;
if (i != len) {
hasQuery = true;
query = schemeSpecificPart.substr(i + 1);
query = schemeSpecificPart.copy(i + 1);
}
return new UriReference(
scheme, hasAuthority, authority, OUString(path), hasQuery, query);
scheme, hasAuthority, authority, path, hasQuery, query);
}
struct Segment {