2014-05-05 17:30:46 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2004-01-21 04:39:58 +00:00
|
|
|
|
2011-08-18 13:46:39 +00:00
|
|
|
int NS_FASTCALL
|
2014-05-27 07:15:35 +00:00
|
|
|
Compare(const nsTSubstring_CharT::base_string_type& aLhs,
|
|
|
|
const nsTSubstring_CharT::base_string_type& aRhs,
|
|
|
|
const nsTStringComparator_CharT& comp)
|
2014-05-05 17:30:46 +00:00
|
|
|
{
|
|
|
|
typedef nsTSubstring_CharT::size_type size_type;
|
2004-01-21 04:39:58 +00:00
|
|
|
|
2014-05-27 07:15:35 +00:00
|
|
|
if (&aLhs == &aRhs) {
|
2014-05-05 17:30:46 +00:00
|
|
|
return 0;
|
2014-05-27 07:15:35 +00:00
|
|
|
}
|
2004-01-21 04:39:58 +00:00
|
|
|
|
2014-05-05 17:30:46 +00:00
|
|
|
nsTSubstring_CharT::const_iterator leftIter, rightIter;
|
2014-05-27 07:15:35 +00:00
|
|
|
aLhs.BeginReading(leftIter);
|
|
|
|
aRhs.BeginReading(rightIter);
|
2004-01-21 04:39:58 +00:00
|
|
|
|
2014-05-05 17:30:46 +00:00
|
|
|
size_type lLength = leftIter.size_forward();
|
|
|
|
size_type rLength = rightIter.size_forward();
|
|
|
|
size_type lengthToCompare = XPCOM_MIN(lLength, rLength);
|
2004-01-21 04:39:58 +00:00
|
|
|
|
2014-05-05 17:30:46 +00:00
|
|
|
int result;
|
2014-05-27 07:15:35 +00:00
|
|
|
if ((result = comp(leftIter.get(), rightIter.get(),
|
|
|
|
lengthToCompare, lengthToCompare)) == 0) {
|
|
|
|
if (lLength < rLength) {
|
2014-05-05 17:30:46 +00:00
|
|
|
result = -1;
|
2014-05-27 07:15:35 +00:00
|
|
|
} else if (rLength < lLength) {
|
2014-05-05 17:30:46 +00:00
|
|
|
result = 1;
|
2014-05-27 07:15:35 +00:00
|
|
|
} else {
|
2014-05-05 17:30:46 +00:00
|
|
|
result = 0;
|
2014-05-27 07:15:35 +00:00
|
|
|
}
|
2004-02-19 02:44:03 +00:00
|
|
|
}
|
|
|
|
|
2014-05-05 17:30:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2004-02-19 02:44:03 +00:00
|
|
|
int
|
2014-05-27 07:15:35 +00:00
|
|
|
nsTDefaultStringComparator_CharT::operator()(const char_type* aLhs,
|
|
|
|
const char_type* aRhs,
|
|
|
|
uint32_t aLLength,
|
|
|
|
uint32_t aRLength) const
|
2014-05-05 17:30:46 +00:00
|
|
|
{
|
2014-05-27 07:15:35 +00:00
|
|
|
return
|
|
|
|
aLLength == aRLength ? nsCharTraits<CharT>::compare(aLhs, aRhs, aLLength) :
|
|
|
|
(aLLength > aRLength) ? 1 : -1;
|
2014-05-05 17:30:46 +00:00
|
|
|
}
|