зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1591191 - Move compare and EqualsIgnoreAsciiCase to nsTStringRepr. r=erahm
Zibi is working on replacing some string based APIs with some things that return substrings, so we could use this. Alternatively he'd have to do something like: Compare(myCSubstring, nsDependentCSubstring(aTag, strlen(aTag))) or something of that sort, which looks a bit uglier. Differential Revision: https://phabricator.services.mozilla.com/D50523 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a02bd2636c
Коммит
7d302de427
|
@ -852,14 +852,13 @@ void nsTString<T>::ReplaceChar(const char* aSet, char16_t aNewChar) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nsTString::Compare,CompareWithConversion,etc.
|
||||
*/
|
||||
namespace mozilla {
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
template <typename Q, typename EnableIfChar>
|
||||
int32_t nsTString<T>::Compare(const char_type* aString, bool aIgnoreCase,
|
||||
int32_t aCount) const {
|
||||
int32_t nsTStringRepr<T>::Compare(const char_type* aString, bool aIgnoreCase,
|
||||
int32_t aCount) const {
|
||||
uint32_t strLen = char_traits::length(aString);
|
||||
|
||||
int32_t maxCount = int32_t(XPCOM_MIN(this->mLength, strLen));
|
||||
|
@ -886,8 +885,8 @@ int32_t nsTString<T>::Compare(const char_type* aString, bool aIgnoreCase,
|
|||
|
||||
template <typename T>
|
||||
template <typename Q, typename EnableIfChar16>
|
||||
bool nsTString<T>::EqualsIgnoreCase(const incompatible_char_type* aString,
|
||||
int32_t aCount) const {
|
||||
bool nsTStringRepr<T>::EqualsIgnoreCase(const incompatible_char_type* aString,
|
||||
int32_t aCount) const {
|
||||
uint32_t strLen = nsCharTraits<char>::length(aString);
|
||||
|
||||
int32_t maxCount = int32_t(XPCOM_MIN(this->mLength, strLen));
|
||||
|
@ -913,6 +912,9 @@ bool nsTString<T>::EqualsIgnoreCase(const incompatible_char_type* aString,
|
|||
return result == 0;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
* nsTString::ToDouble
|
||||
*/
|
||||
|
|
|
@ -281,35 +281,6 @@ class nsTString : public nsTSubstring<T> {
|
|||
return RFindCharInSet(aString.get(), aOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares a given string to this string.
|
||||
*
|
||||
* @param aString is the string to be compared
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to compare
|
||||
* @return -1,0,1
|
||||
*/
|
||||
template <typename Q = T, typename EnableIfChar = mozilla::CharOnlyT<Q>>
|
||||
int32_t Compare(const char_type* aString, bool aIgnoreCase = false,
|
||||
int32_t aCount = -1) const;
|
||||
|
||||
/**
|
||||
* Equality check between given string and this string.
|
||||
*
|
||||
* @param aString is the string to check
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to compare
|
||||
* @return boolean
|
||||
*/
|
||||
template <typename Q = T, typename EnableIfChar = mozilla::CharOnlyT<Q>>
|
||||
bool EqualsIgnoreCase(const char_type* aString, int32_t aCount = -1) const {
|
||||
return Compare(aString, true, aCount) == 0;
|
||||
}
|
||||
|
||||
template <typename Q = T, typename EnableIfChar16 = mozilla::Char16OnlyT<Q>>
|
||||
bool EqualsIgnoreCase(const incompatible_char_type* aString,
|
||||
int32_t aCount = -1) const;
|
||||
|
||||
/**
|
||||
* Perform string to double-precision float conversion.
|
||||
*
|
||||
|
|
|
@ -207,6 +207,35 @@ class nsTStringRepr {
|
|||
bool NS_FASTCALL Equals(const char_type* aData,
|
||||
const comparator_type& aComp) const;
|
||||
|
||||
/**
|
||||
* Compares a given string to this string.
|
||||
*
|
||||
* @param aString is the string to be compared
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to compare
|
||||
* @return -1,0,1
|
||||
*/
|
||||
template <typename Q = T, typename EnableIfChar = mozilla::CharOnlyT<Q>>
|
||||
int32_t Compare(const char_type* aString, bool aIgnoreCase = false,
|
||||
int32_t aCount = -1) const;
|
||||
|
||||
/**
|
||||
* Equality check between given string and this string.
|
||||
*
|
||||
* @param aString is the string to check
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @param aCount tells us how many chars to compare
|
||||
* @return boolean
|
||||
*/
|
||||
template <typename Q = T, typename EnableIfChar = mozilla::CharOnlyT<Q>>
|
||||
bool EqualsIgnoreCase(const char_type* aString, int32_t aCount = -1) const {
|
||||
return Compare(aString, true, aCount) == 0;
|
||||
}
|
||||
|
||||
template <typename Q = T, typename EnableIfChar16 = mozilla::Char16OnlyT<Q>>
|
||||
bool EqualsIgnoreCase(const incompatible_char_type* aString,
|
||||
int32_t aCount = -1) const;
|
||||
|
||||
#if defined(MOZ_USE_CHAR16_WRAPPER)
|
||||
template <typename Q = T, typename EnableIfChar16 = Char16OnlyT<Q>>
|
||||
bool NS_FASTCALL Equals(char16ptr_t aData) const {
|
||||
|
|
Загрузка…
Ссылка в новой задаче