1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 Compare(const nsTSubstring_CharT::base_string_type
& aLhs
,
9 const nsTSubstring_CharT::base_string_type
& aRhs
,
10 const nsTStringComparator_CharT
& comp
)
12 typedef nsTSubstring_CharT::size_type size_type
;
18 nsTSubstring_CharT::const_iterator leftIter
, rightIter
;
19 aLhs
.BeginReading(leftIter
);
20 aRhs
.BeginReading(rightIter
);
22 size_type lLength
= leftIter
.size_forward();
23 size_type rLength
= rightIter
.size_forward();
24 size_type lengthToCompare
= XPCOM_MIN(lLength
, rLength
);
27 if ((result
= comp(leftIter
.get(), rightIter
.get(),
28 lengthToCompare
, lengthToCompare
)) == 0) {
29 if (lLength
< rLength
) {
31 } else if (rLength
< lLength
) {
42 nsTDefaultStringComparator_CharT::operator()(const char_type
* aLhs
,
43 const char_type
* aRhs
,
45 uint32_t aRLength
) const
48 aLLength
== aRLength
? nsCharTraits
<CharT
>::compare(aLhs
, aRhs
, aLLength
) :
49 (aLLength
> aRLength
) ? 1 : -1;