1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <svl/sharedstring.hxx>
14 const OUString
SharedString::EMPTY_STRING
;
16 const SharedString
& SharedString::getEmptyString()
18 // ref-counting traffic associated with SharedString temporaries can be significant,
19 // so use a singleton here, so we can return a const& from getEmptyString.
20 // unicode string array for empty string is globally shared in OUString.
21 // Let's take advantage of that.
22 static const SharedString
EMPTY_SHARED_STRING(EMPTY_STRING
.pData
, EMPTY_STRING
.pData
);
23 return EMPTY_SHARED_STRING
;
26 SharedString
& SharedString::operator= ( const SharedString
& r
)
32 rtl_uString_release(mpData
);
34 rtl_uString_release(mpDataIgnoreCase
);
37 mpDataIgnoreCase
= r
.mpDataIgnoreCase
;
40 rtl_uString_acquire(mpData
);
42 rtl_uString_acquire(mpDataIgnoreCase
);
47 bool SharedString::operator== ( const SharedString
& r
) const
49 // Compare only the original (not case-folded) string.
51 if (mpData
== r
.mpData
)
54 if (!mpData
|| !r
.mpData
)
57 if (mpData
->length
!= r
.mpData
->length
)
60 return rtl_ustr_reverseCompare_WithLength(mpData
->buffer
, mpData
->length
, r
.mpData
->buffer
, r
.mpData
->length
) == 0;
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */