michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: int NS_FASTCALL michael@0: Compare( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs, const nsTStringComparator_CharT& comp ) michael@0: { michael@0: typedef nsTSubstring_CharT::size_type size_type; michael@0: michael@0: if ( &lhs == &rhs ) michael@0: return 0; michael@0: michael@0: nsTSubstring_CharT::const_iterator leftIter, rightIter; michael@0: lhs.BeginReading(leftIter); michael@0: rhs.BeginReading(rightIter); michael@0: michael@0: size_type lLength = leftIter.size_forward(); michael@0: size_type rLength = rightIter.size_forward(); michael@0: size_type lengthToCompare = XPCOM_MIN(lLength, rLength); michael@0: michael@0: int result; michael@0: if ( (result = comp(leftIter.get(), rightIter.get(), lengthToCompare, lengthToCompare)) == 0 ) michael@0: { michael@0: if ( lLength < rLength ) michael@0: result = -1; michael@0: else if ( rLength < lLength ) michael@0: result = 1; michael@0: else michael@0: result = 0; michael@0: } michael@0: michael@0: return result; michael@0: } michael@0: michael@0: int michael@0: nsTDefaultStringComparator_CharT::operator()( const char_type* lhs, const char_type* rhs, uint32_t lLength, uint32_t rLength) const michael@0: { michael@0: return (lLength == rLength) ? nsCharTraits::compare(lhs, rhs, lLength) : michael@0: (lLength > rLength) ? 1 : -1; michael@0: }